From 55874470ff6d619dd05d8c344d4b3c3205982eae Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 2 Feb 2018 18:01:17 +0100 Subject: [PATCH] gtk: Remove GtkRecentChooser It's not used any more, recent files are only used by the filtchooser and that one uses GtkRecentManager directly. --- docs/reference/gtk/gtk4-docs.xml | 5 - docs/reference/gtk/gtk4-sections.txt | 137 -- .../gtk/images/recentchooserdialog.png | Bin 33249 -> 0 bytes docs/reference/gtk/meson.build | 1 - docs/reference/gtk/visual_index.xml | 3 - docs/tools/widgets.c | 20 - gtk/gtk-autocleanups.h | 5 - gtk/gtk.h | 5 - gtk/gtkrecentchooser.c | 999 ---------- gtk/gtkrecentchooser.h | 263 --- gtk/gtkrecentchooserdefault.c | 1707 ----------------- gtk/gtkrecentchooserdefault.h | 40 - gtk/gtkrecentchooserdialog.c | 360 ---- gtk/gtkrecentchooserdialog.h | 81 - gtk/gtkrecentchoosermenu.c | 1248 ------------ gtk/gtkrecentchoosermenu.h | 77 - gtk/gtkrecentchooserprivate.h | 40 - gtk/gtkrecentchooserutils.c | 530 ----- gtk/gtkrecentchooserutils.h | 60 - gtk/gtkrecentchooserwidget.c | 237 --- gtk/gtkrecentchooserwidget.h | 71 - gtk/gtkrecentfilter.c | 837 -------- gtk/gtkrecentfilter.h | 150 -- gtk/meson.build | 13 - gtk/ui/gtkrecentchooserdefault.ui | 88 - gtk/ui/gtkrecentchooserdefault.ui.h | 1 - po-properties/POTFILES.in | 3 - po-properties/POTFILES.skip | 2 - tests/meson.build | 2 - tests/popupat.ui | 21 - tests/testrecentchooser.c | 200 -- tests/testrecentchoosermenu.c | 183 -- testsuite/gtk/templates.c | 11 - 33 files changed, 7400 deletions(-) delete mode 100644 docs/reference/gtk/images/recentchooserdialog.png delete mode 100644 gtk/gtkrecentchooser.c delete mode 100644 gtk/gtkrecentchooser.h delete mode 100644 gtk/gtkrecentchooserdefault.c delete mode 100644 gtk/gtkrecentchooserdefault.h delete mode 100644 gtk/gtkrecentchooserdialog.c delete mode 100644 gtk/gtkrecentchooserdialog.h delete mode 100644 gtk/gtkrecentchoosermenu.c delete mode 100644 gtk/gtkrecentchoosermenu.h delete mode 100644 gtk/gtkrecentchooserprivate.h delete mode 100644 gtk/gtkrecentchooserutils.c delete mode 100644 gtk/gtkrecentchooserutils.h delete mode 100644 gtk/gtkrecentchooserwidget.c delete mode 100644 gtk/gtkrecentchooserwidget.h delete mode 100644 gtk/gtkrecentfilter.c delete mode 100644 gtk/gtkrecentfilter.h delete mode 100644 gtk/ui/gtkrecentchooserdefault.ui delete mode 100644 gtk/ui/gtkrecentchooserdefault.ui.h delete mode 100644 tests/testrecentchooser.c delete mode 100644 tests/testrecentchoosermenu.c diff --git a/docs/reference/gtk/gtk4-docs.xml b/docs/reference/gtk/gtk4-docs.xml index 4bb2f0e612..fa4417a041 100644 --- a/docs/reference/gtk/gtk4-docs.xml +++ b/docs/reference/gtk/gtk4-docs.xml @@ -276,11 +276,6 @@ Recently Used Documents - - - - - diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index b4ef5fabf8..fd0c3229e9 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -2179,143 +2179,6 @@ gtk_range_get_type GtkRangePrivate -
-gtkrecentchooser -GtkRecentChooser -GtkRecentChooser -GtkRecentChooserIface -GTK_RECENT_CHOOSER_ERROR -GtkRecentChooserError -gtk_recent_chooser_set_show_private -gtk_recent_chooser_get_show_private -gtk_recent_chooser_set_show_not_found -gtk_recent_chooser_get_show_not_found -gtk_recent_chooser_set_show_icons -gtk_recent_chooser_get_show_icons -gtk_recent_chooser_set_select_multiple -gtk_recent_chooser_get_select_multiple -gtk_recent_chooser_set_local_only -gtk_recent_chooser_get_local_only -gtk_recent_chooser_set_limit -gtk_recent_chooser_get_limit -gtk_recent_chooser_set_show_tips -gtk_recent_chooser_get_show_tips -GtkRecentSortType -gtk_recent_chooser_set_sort_type -gtk_recent_chooser_get_sort_type -GtkRecentSortFunc -gtk_recent_chooser_set_sort_func -gtk_recent_chooser_set_current_uri -gtk_recent_chooser_get_current_uri -gtk_recent_chooser_get_current_item -gtk_recent_chooser_select_uri -gtk_recent_chooser_unselect_uri -gtk_recent_chooser_select_all -gtk_recent_chooser_unselect_all -gtk_recent_chooser_get_items -gtk_recent_chooser_get_uris -gtk_recent_chooser_add_filter -gtk_recent_chooser_remove_filter -gtk_recent_chooser_list_filters -gtk_recent_chooser_set_filter -gtk_recent_chooser_get_filter - -GTK_RECENT_CHOOSER -GTK_IS_RECENT_CHOOSER -GTK_TYPE_RECENT_CHOOSER -GTK_RECENT_CHOOSER_GET_IFACE - -gtk_recent_chooser_get_type -gtk_recent_chooser_error_quark -
- -
-gtkrecentchooserdialog -GtkRecentChooserDialog -GtkRecentChooserDialog -gtk_recent_chooser_dialog_new -gtk_recent_chooser_dialog_new_for_manager - -GTK_RECENT_CHOOSER_DIALOG -GTK_IS_RECENT_CHOOSER_DIALOG -GTK_TYPE_RECENT_CHOOSER_DIALOG -GTK_RECENT_CHOOSER_DIALOG_CLASS -GTK_IS_RECENT_CHOOSER_DIALOG_CLASS -GTK_RECENT_CHOOSER_DIALOG_GET_CLASS - - -gtk_recent_chooser_dialog_get_type -GtkRecentChooserDialogPrivate -
- -
-gtkrecentchoosermenu -GtkRecentChooserMenu -GtkRecentChooserMenu -gtk_recent_chooser_menu_new -gtk_recent_chooser_menu_new_for_manager -gtk_recent_chooser_menu_get_show_numbers -gtk_recent_chooser_menu_set_show_numbers - -GTK_RECENT_CHOOSER_MENU -GTK_IS_RECENT_CHOOSER_MENU -GTK_TYPE_RECENT_CHOOSER_MENU -GTK_RECENT_CHOOSER_MENU_CLASS -GTK_IS_RECENT_CHOOSER_MENU_CLASS -GTK_RECENT_CHOOSER_MENU_GET_CLASS - - -gtk_recent_chooser_menu_get_type -GtkRecentChooserMenuPrivate -
- -
-gtkrecentchooserwidget -GtkRecentChooserWidget -GtkRecentChooserWidget -gtk_recent_chooser_widget_new -gtk_recent_chooser_widget_new_for_manager - -GTK_RECENT_CHOOSER_WIDGET -GTK_IS_RECENT_CHOOSER_WIDGET -GTK_TYPE_RECENT_CHOOSER_WIDGET -GTK_RECENT_CHOOSER_WIDGET_CLASS -GTK_IS_RECENT_CHOOSER_WIDGET_CLASS -GTK_RECENT_CHOOSER_WIDGET_GET_CLASS - - -gtk_recent_chooser_widget_get_type -GtkRecentChooserWidgetPrivate -
- -
-gtkrecentfilter -GtkRecentFilter -GtkRecentFilter -GtkRecentFilterInfo -GtkRecentFilterFlags -GtkRecentFilterFunc -gtk_recent_filter_new -gtk_recent_filter_get_name -gtk_recent_filter_set_name -gtk_recent_filter_add_mime_type -gtk_recent_filter_add_pattern -gtk_recent_filter_add_pixbuf_formats -gtk_recent_filter_add_application -gtk_recent_filter_add_group -gtk_recent_filter_add_age -gtk_recent_filter_add_custom -gtk_recent_filter_get_needed -gtk_recent_filter_filter - -GTK_RECENT_FILTER -GTK_IS_RECENT_FILTER -GTK_TYPE_RECENT_FILTER - - -gtk_recent_filter_get_type -
-
gtkrecentmanager GtkRecentManager diff --git a/docs/reference/gtk/images/recentchooserdialog.png b/docs/reference/gtk/images/recentchooserdialog.png deleted file mode 100644 index b01c08a37230be3c38ba3ae2df7d48ca016c1f5e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33249 zcmdSBbySpLyEi(5gtXEiARyf(4N6LPr*wyOgHn>x4FUqv(%sVC4bt7+-#zcU-+lHu z-`;Dz-&*I7b6g`c!0<5hJokNFzq1j>u}XfpTv~mf zN}Uy%<@<)36$?w`b+ELkcQ7nM7lKNu^{U3fPNG~WrmiOP)WCTBKY?!|b6Z?|~?#He&4)`3q zR1>~;7bC1d7#|#2In4t5O(82ac9r#uSRurdBUR-$ML5sO3%9O+WoSP2QV3C@P7=wi6HY|x<&j!J9};6HTxa_iqsNxeemO)^k&D$HSA$1=b?YzL z)vu}*)aB`Ext6T<6rkTy(SAR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xYuv@Mysi)s}I_4 z^ausS-95F%yf;%fSeA74s@RKCUVnxGC=y5Q)TG7$9I#7WA@EuL8b(9L`2m?8A-q4; zhWV`3OJ9-YcT-4wnQ#qHb<9r2=buS4Htiox>o3QVV}FaCKW)}5m8Hc-sdefj)}9o> zV0{no70))ZW>Eze_P7{Z)0Y3R*S#Txo~Q;%{vMWRn8LjjG9 zx=(HG+-L;wOxWxDq*0gATXjD;SQu}?#^Tm)lyZa0v8XqfNOR7lo@Ze*P$-S2B1x5d z?~zR;Oc@rD`gLiLeRi}huhT?Bm%G>ySK4WBk9|&rri9FxigU3o<^tOo{te8z|D;oN z>BHjLdl8z%q4{SX(HFA^Gv$QSve)OQGgB^l%xDcVG%a$ae$EqA2 z^ECNW+G0>olqzO+alrj?_KBRDH`=^L9QCArXNKzY^E~t#JFlCl<2CE-t9>@E%`7Di z7-YBGtv1@#wIfsGExxkJX+UjL*&|Awn@*5rUB#Sw7tU2q8IjyK+F|5MQ+x;qkAqde zIU5|H!T3zk5yuhe-qpS#Ho@iT6a(2>Y!z`TZf^U75q+#QEYb%uhNBi-e z3xi)i1U|rDa6PsofHUntN z9JvUM9RFnWsTF@n{|D(9DAH?;-!;tfUKw8#kvD7p>>$itccn1TD;t5Qyyo`GtLk65NK-+NE6 z>Y(tZ^kqt>movSY@CKJqn`~w7gDQ11iWZ%5z!msFN5 x@@!wWHaDC>;koGZQt&6-CI3JEGZt_x$;bP`H#d*R7XiQS$SU2+kv4qse*mMX-cSGl diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build index a124564b76..f94454fb2c 100644 --- a/docs/reference/gtk/meson.build +++ b/docs/reference/gtk/meson.build @@ -112,7 +112,6 @@ images = [ 'images/printdialog.png', 'images/progressbar.png', 'images/radio-group.png', - 'images/recentchooserdialog.png', 'images/right-center.png', 'images/right-end.png', 'images/right-start.png', diff --git a/docs/reference/gtk/visual_index.xml b/docs/reference/gtk/visual_index.xml index c3f3776758..2eadeae47c 100644 --- a/docs/reference/gtk/visual_index.xml +++ b/docs/reference/gtk/visual_index.xml @@ -198,9 +198,6 @@ - - - diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c index 33c8590fde..6feaf98759 100644 --- a/docs/tools/widgets.c +++ b/docs/tools/widgets.c @@ -448,25 +448,6 @@ create_action_bar (void) return info; } -static WidgetInfo * -create_recent_chooser_dialog (void) -{ - WidgetInfo *info; - GtkWidget *widget; - - widget = gtk_recent_chooser_dialog_new ("Recent Chooser Dialog", - NULL, - "Cancel", GTK_RESPONSE_CANCEL, - "Open", GTK_RESPONSE_ACCEPT, - NULL); - gtk_window_set_default_size (GTK_WINDOW (widget), 505, 305); - - info = new_widget_info ("recentchooserdialog", widget, ASIS); - info->include_decorations = TRUE; - - return info; -} - static WidgetInfo * create_text_view (void) { @@ -1511,7 +1492,6 @@ get_all_widgets (void) retval = g_list_prepend (retval, create_window ()); retval = g_list_prepend (retval, create_filesel ()); retval = g_list_prepend (retval, create_assistant ()); - retval = g_list_prepend (retval, create_recent_chooser_dialog ()); retval = g_list_prepend (retval, create_page_setup_dialog ()); retval = g_list_prepend (retval, create_print_dialog ()); retval = g_list_prepend (retval, create_volume_button ()); diff --git a/gtk/gtk-autocleanups.h b/gtk/gtk-autocleanups.h index caccfe57d5..a4bd93691e 100644 --- a/gtk/gtk-autocleanups.h +++ b/gtk/gtk-autocleanups.h @@ -130,11 +130,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioButton, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioMenuItem, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioToolButton, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRange, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooser, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooserDialog, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooserMenu, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooserWidget, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentFilter, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentManager, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRevealer, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkScale, g_object_unref) diff --git a/gtk/gtk.h b/gtk/gtk.h index acd5b76832..1d23fc10fa 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -167,11 +167,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include diff --git a/gtk/gtkrecentchooser.c b/gtk/gtkrecentchooser.c deleted file mode 100644 index 828c64cef1..0000000000 --- a/gtk/gtkrecentchooser.c +++ /dev/null @@ -1,999 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooser.c - Abstract interface for recent file selectors GUIs - * - * Copyright (C) 2006, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include "gtkrecentchooser.h" -#include "gtkrecentchooserprivate.h" -#include "gtkrecentmanager.h" -#include "gtkintl.h" -#include "gtktypebuiltins.h" -#include "gtkprivate.h" -#include "gtkmarshalers.h" - -/** - * SECTION:gtkrecentchooser - * @Short_description: Interface implemented by widgets displaying recently - * used files - * @Title: GtkRecentChooser - * @See_also: #GtkRecentManager, #GtkRecentChooserDialog, - * #GtkRecentChooserWidget, #GtkRecentChooserMenu - * - * #GtkRecentChooser is an interface that can be implemented by widgets - * displaying the list of recently used files. In GTK+, the main objects - * that implement this interface are #GtkRecentChooserWidget, - * #GtkRecentChooserDialog and #GtkRecentChooserMenu. - * - * Recently used files are supported since GTK+ 2.10. - */ - - -enum -{ - ITEM_ACTIVATED, - SELECTION_CHANGED, - - LAST_SIGNAL -}; - -static guint chooser_signals[LAST_SIGNAL] = { 0, }; - - -typedef GtkRecentChooserIface GtkRecentChooserInterface; -G_DEFINE_INTERFACE (GtkRecentChooser, gtk_recent_chooser, G_TYPE_OBJECT); - - -static void -gtk_recent_chooser_default_init (GtkRecentChooserInterface *iface) -{ - GType iface_type = G_TYPE_FROM_INTERFACE (iface); - - /** - * GtkRecentChooser::selection-changed: - * @chooser: the object which received the signal - * - * This signal is emitted when there is a change in the set of - * selected recently used resources. This can happen when a user - * modifies the selection with the mouse or the keyboard, or when - * explicitly calling functions to change the selection. - * - * Since: 2.10 - */ - chooser_signals[SELECTION_CHANGED] = - g_signal_new (I_("selection-changed"), - iface_type, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkRecentChooserIface, selection_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * GtkRecentChooser::item-activated: - * @chooser: the object which received the signal - * - * This signal is emitted when the user "activates" a recent item - * in the recent chooser. This can happen by double-clicking on an item - * in the recently used resources list, or by pressing - * `Enter`. - * - * Since: 2.10 - */ - chooser_signals[ITEM_ACTIVATED] = - g_signal_new (I_("item-activated"), - iface_type, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkRecentChooserIface, item_activated), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * GtkRecentChooser:recent-manager: - * - * The #GtkRecentManager instance used by the #GtkRecentChooser to - * display the list of recently used resources. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_object ("recent-manager", - P_("Recent Manager"), - P_("The RecentManager object to use"), - GTK_TYPE_RECENT_MANAGER, - GTK_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY)); - - /** - * GtkRecentManager:show-private: - * - * Whether this #GtkRecentChooser should display recently used resources - * marked with the "private" flag. Such resources should be considered - * private to the applications and groups that have added them. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_boolean ("show-private", - P_("Show Private"), - P_("Whether the private items should be displayed"), - FALSE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:show-tips: - * - * Whether this #GtkRecentChooser should display a tooltip containing the - * full path of the recently used resources. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_boolean ("show-tips", - P_("Show Tooltips"), - P_("Whether there should be a tooltip on the item"), - FALSE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:show-icons: - * - * Whether this #GtkRecentChooser should display an icon near the item. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_boolean ("show-icons", - P_("Show Icons"), - P_("Whether there should be an icon near the item"), - TRUE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:show-not-found: - * - * Whether this #GtkRecentChooser should display the recently used resources - * even if not present anymore. Setting this to %FALSE will perform a - * potentially expensive check on every local resource (every remote - * resource will always be displayed). - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_boolean ("show-not-found", - P_("Show Not Found"), - P_("Whether the items pointing to unavailable resources should be displayed"), - TRUE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:select-multiple: - * - * Allow the user to select multiple resources. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_boolean ("select-multiple", - P_("Select Multiple"), - P_("Whether to allow multiple items to be selected"), - FALSE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:local-only: - * - * Whether this #GtkRecentChooser should display only local (file:) - * resources. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_boolean ("local-only", - P_("Local only"), - P_("Whether the selected resource(s) should be limited to local file: URIs"), - TRUE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:limit: - * - * The maximum number of recently used resources to be displayed, - * or -1 to display all items. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_int ("limit", - P_("Limit"), - P_("The maximum number of items to be displayed"), - -1, G_MAXINT, 50, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:sort-type: - * - * Sorting order to be used when displaying the recently used resources. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_enum ("sort-type", - P_("Sort Type"), - P_("The sorting order of the items displayed"), - GTK_TYPE_RECENT_SORT_TYPE, - GTK_RECENT_SORT_NONE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); - - /** - * GtkRecentChooser:filter: - * - * The #GtkRecentFilter object to be used when displaying - * the recently used resources. - * - * Since: 2.10 - */ - g_object_interface_install_property (iface, - g_param_spec_object ("filter", - P_("Filter"), - P_("The current filter for selecting which resources are displayed"), - GTK_TYPE_RECENT_FILTER, - GTK_PARAM_READWRITE)); -} - -GQuark -gtk_recent_chooser_error_quark (void) -{ - return g_quark_from_static_string ("gtk-recent-chooser-error-quark"); -} - -/** - * _gtk_recent_chooser_get_recent_manager: - * @chooser: a #GtkRecentChooser - * - * Gets the #GtkRecentManager used by @chooser. - * - * Returns: the recent manager for @chooser. - * - * Since: 2.10 - */ -GtkRecentManager * -_gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_recent_manager (chooser); -} - -/** - * gtk_recent_chooser_set_show_private: - * @chooser: a #GtkRecentChooser - * @show_private: %TRUE to show private items, %FALSE otherwise - * - * Whether to show recently used resources marked registered as private. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser, - gboolean show_private) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "show-private", show_private, NULL); -} - -/** - * gtk_recent_chooser_get_show_private: - * @chooser: a #GtkRecentChooser - * - * Returns whether @chooser should display recently used resources - * registered as private. - * - * Returns: %TRUE if the recent chooser should show private items, - * %FALSE otherwise. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser) -{ - gboolean show_private; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - g_object_get (chooser, "show-private", &show_private, NULL); - - return show_private; -} - -/** - * gtk_recent_chooser_set_show_not_found: - * @chooser: a #GtkRecentChooser - * @show_not_found: whether to show the local items we didn’t find - * - * Sets whether @chooser should display the recently used resources that - * it didn’t find. This only applies to local resources. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser, - gboolean show_not_found) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "show-not-found", show_not_found, NULL); -} - -/** - * gtk_recent_chooser_get_show_not_found: - * @chooser: a #GtkRecentChooser - * - * Retrieves whether @chooser should show the recently used resources that - * were not found. - * - * Returns: %TRUE if the resources not found should be displayed, and - * %FALSE otheriwse. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser) -{ - gboolean show_not_found; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - g_object_get (chooser, "show-not-found", &show_not_found, NULL); - - return show_not_found; -} - -/** - * gtk_recent_chooser_set_show_icons: - * @chooser: a #GtkRecentChooser - * @show_icons: whether to show an icon near the resource - * - * Sets whether @chooser should show an icon near the resource when - * displaying it. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser, - gboolean show_icons) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "show-icons", show_icons, NULL); -} - -/** - * gtk_recent_chooser_get_show_icons: - * @chooser: a #GtkRecentChooser - * - * Retrieves whether @chooser should show an icon near the resource. - * - * Returns: %TRUE if the icons should be displayed, %FALSE otherwise. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser) -{ - gboolean show_icons; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - g_object_get (chooser, "show-icons", &show_icons, NULL); - - return show_icons; -} - -/** - * gtk_recent_chooser_set_select_multiple: - * @chooser: a #GtkRecentChooser - * @select_multiple: %TRUE if @chooser can select more than one item - * - * Sets whether @chooser can select multiple items. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser, - gboolean select_multiple) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "select-multiple", select_multiple, NULL); -} - -/** - * gtk_recent_chooser_get_select_multiple: - * @chooser: a #GtkRecentChooser - * - * Gets whether @chooser can select multiple items. - * - * Returns: %TRUE if @chooser can select more than one item. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser) -{ - gboolean select_multiple; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - g_object_get (chooser, "select-multiple", &select_multiple, NULL); - - return select_multiple; -} - -/** - * gtk_recent_chooser_set_local_only: - * @chooser: a #GtkRecentChooser - * @local_only: %TRUE if only local files can be shown - * - * Sets whether only local resources, that is resources using the file:// URI - * scheme, should be shown in the recently used resources selector. If - * @local_only is %TRUE (the default) then the shown resources are guaranteed - * to be accessible through the operating system native file system. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser, - gboolean local_only) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "local-only", local_only, NULL); -} - -/** - * gtk_recent_chooser_get_local_only: - * @chooser: a #GtkRecentChooser - * - * Gets whether only local resources should be shown in the recently used - * resources selector. See gtk_recent_chooser_set_local_only() - * - * Returns: %TRUE if only local resources should be shown. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser) -{ - gboolean local_only; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - g_object_get (chooser, "local-only", &local_only, NULL); - - return local_only; -} - -/** - * gtk_recent_chooser_set_limit: - * @chooser: a #GtkRecentChooser - * @limit: a positive integer, or -1 for all items - * - * Sets the number of items that should be returned by - * gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris(). - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_limit (GtkRecentChooser *chooser, - gint limit) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "limit", limit, NULL); -} - -/** - * gtk_recent_chooser_get_limit: - * @chooser: a #GtkRecentChooser - * - * Gets the number of items returned by gtk_recent_chooser_get_items() - * and gtk_recent_chooser_get_uris(). - * - * Returns: A positive integer, or -1 meaning that all items are - * returned. - * - * Since: 2.10 - */ -gint -gtk_recent_chooser_get_limit (GtkRecentChooser *chooser) -{ - gint limit; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), 10); - - g_object_get (chooser, "limit", &limit, NULL); - - return limit; -} - -/** - * gtk_recent_chooser_set_show_tips: - * @chooser: a #GtkRecentChooser - * @show_tips: %TRUE if tooltips should be shown - * - * Sets whether to show a tooltips containing the full path of each - * recently used resource in a #GtkRecentChooser widget. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser, - gboolean show_tips) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "show-tips", show_tips, NULL); -} - -/** - * gtk_recent_chooser_get_show_tips: - * @chooser: a #GtkRecentChooser - * - * Gets whether @chooser should display tooltips containing the full path - * of a recently user resource. - * - * Returns: %TRUE if the recent chooser should show tooltips, - * %FALSE otherwise. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser) -{ - gboolean show_tips; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - g_object_get (chooser, "show-tips", &show_tips, NULL); - - return show_tips; -} - -/** - * gtk_recent_chooser_set_sort_type: - * @chooser: a #GtkRecentChooser - * @sort_type: sort order that the chooser should use - * - * Changes the sorting order of the recently used resources list displayed by - * @chooser. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser, - GtkRecentSortType sort_type) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_object_set (chooser, "sort-type", sort_type, NULL); -} - -/** - * gtk_recent_chooser_get_sort_type: - * @chooser: a #GtkRecentChooser - * - * Gets the value set by gtk_recent_chooser_set_sort_type(). - * - * Returns: the sorting order of the @chooser. - * - * Since: 2.10 - */ -GtkRecentSortType -gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser) -{ - GtkRecentSortType sort_type; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_NONE); - - g_object_get (chooser, "sort-type", &sort_type, NULL); - - return sort_type; -} - -/** - * gtk_recent_chooser_set_sort_func: - * @chooser: a #GtkRecentChooser - * @sort_func: the comparison function - * @sort_data: (allow-none): user data to pass to @sort_func, or %NULL - * @data_destroy: (allow-none): destroy notifier for @sort_data, or %NULL - * - * Sets the comparison function used when sorting to be @sort_func. If - * the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then - * the chooser will sort using this function. - * - * To the comparison function will be passed two #GtkRecentInfo structs and - * @sort_data; @sort_func should return a positive integer if the first - * item comes before the second, zero if the two items are equal and - * a negative integer if the first item comes after the second. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_sort_func (chooser, - sort_func, - sort_data, - data_destroy); -} - -/** - * gtk_recent_chooser_set_current_uri: - * @chooser: a #GtkRecentChooser - * @uri: a URI - * @error: (allow-none): return location for a #GError, or %NULL - * - * Sets @uri as the current URI for @chooser. - * - * Returns: %TRUE if the URI was found. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_current_uri (chooser, uri, error); -} - -/** - * gtk_recent_chooser_get_current_uri: - * @chooser: a #GtkRecentChooser - * - * Gets the URI currently selected by @chooser. - * - * Returns: a newly allocated string holding a URI. - * - * Since: 2.10 - */ -gchar * -gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_current_uri (chooser); -} - -/** - * gtk_recent_chooser_get_current_item: - * @chooser: a #GtkRecentChooser - * - * Gets the #GtkRecentInfo currently selected by @chooser. - * - * Returns: a #GtkRecentInfo. Use gtk_recent_info_unref() when - * when you have finished using it. - * - * Since: 2.10 - */ -GtkRecentInfo * -gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser) -{ - GtkRecentManager *manager; - GtkRecentInfo *retval; - gchar *uri; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - uri = gtk_recent_chooser_get_current_uri (chooser); - if (!uri) - return NULL; - - manager = _gtk_recent_chooser_get_recent_manager (chooser); - retval = gtk_recent_manager_lookup_item (manager, uri, NULL); - g_free (uri); - - return retval; -} - -/** - * gtk_recent_chooser_select_uri: - * @chooser: a #GtkRecentChooser - * @uri: a URI - * @error: (allow-none): return location for a #GError, or %NULL - * - * Selects @uri inside @chooser. - * - * Returns: %TRUE if @uri was found. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE); - - return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_uri (chooser, uri, error); -} - -/** - * gtk_recent_chooser_unselect_uri: - * @chooser: a #GtkRecentChooser - * @uri: a URI - * - * Unselects @uri inside @chooser. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_uri (chooser, uri); -} - -/** - * gtk_recent_chooser_select_all: - * @chooser: a #GtkRecentChooser - * - * Selects all the items inside @chooser, if the @chooser supports - * multiple selection. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_select_all (GtkRecentChooser *chooser) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_all (chooser); -} - -/** - * gtk_recent_chooser_unselect_all: - * @chooser: a #GtkRecentChooser - * - * Unselects all the items inside @chooser. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser); -} - -/** - * gtk_recent_chooser_get_items: - * @chooser: a #GtkRecentChooser - * - * Gets the list of recently used resources in form of #GtkRecentInfo objects. - * - * The return value of this function is affected by the “sort-type” and - * “limit” properties of @chooser. - * - * Returns: (element-type GtkRecentInfo) (transfer full): A newly allocated - * list of #GtkRecentInfo objects. You should - * use gtk_recent_info_unref() on every item of the list, and then free - * the list itself using g_list_free(). - * - * Since: 2.10 - */ -GList * -gtk_recent_chooser_get_items (GtkRecentChooser *chooser) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_items (chooser); -} - -/** - * gtk_recent_chooser_get_uris: - * @chooser: a #GtkRecentChooser - * @length: (out) (allow-none): return location for a the length of the - * URI list, or %NULL - * - * Gets the URI of the recently used resources. - * - * The return value of this function is affected by the “sort-type” and “limit” - * properties of @chooser. - * - * Since the returned array is %NULL terminated, @length may be %NULL. - * - * Returns: (array length=length zero-terminated=1) (transfer full): - * A newly allocated, %NULL-terminated array of strings. Use - * g_strfreev() to free it. - * - * Since: 2.10 - */ -gchar ** -gtk_recent_chooser_get_uris (GtkRecentChooser *chooser, - gsize *length) -{ - GList *items, *l; - gchar **retval; - gsize n_items, i; - - items = gtk_recent_chooser_get_items (chooser); - - n_items = g_list_length (items); - retval = g_new0 (gchar *, n_items + 1); - - for (l = items, i = 0; l != NULL; l = l->next) - { - GtkRecentInfo *info = (GtkRecentInfo *) l->data; - const gchar *uri; - - g_assert (info != NULL); - - uri = gtk_recent_info_get_uri (info); - g_assert (uri != NULL); - - retval[i++] = g_strdup (uri); - } - retval[i] = NULL; - - if (length) - *length = i; - - g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref); - - return retval; -} - -/** - * gtk_recent_chooser_add_filter: - * @chooser: a #GtkRecentChooser - * @filter: a #GtkRecentFilter - * - * Adds @filter to the list of #GtkRecentFilter objects held by @chooser. - * - * If no previous filter objects were defined, this function will call - * gtk_recent_chooser_set_filter(). - * - * Since: 2.10 - */ -void -gtk_recent_chooser_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - - GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter); -} - -/** - * gtk_recent_chooser_remove_filter: - * @chooser: a #GtkRecentChooser - * @filter: a #GtkRecentFilter - * - * Removes @filter from the list of #GtkRecentFilter objects held by @chooser. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - - GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter); -} - -/** - * gtk_recent_chooser_list_filters: - * @chooser: a #GtkRecentChooser - * - * Gets the #GtkRecentFilter objects held by @chooser. - * - * Returns: (element-type GtkRecentFilter) (transfer container): A singly linked list - * of #GtkRecentFilter objects. You - * should just free the returned list using g_slist_free(). - * - * Since: 2.10 - */ -GSList * -gtk_recent_chooser_list_filters (GtkRecentChooser *chooser) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->list_filters (chooser); -} - -/** - * gtk_recent_chooser_set_filter: - * @chooser: a #GtkRecentChooser - * @filter: (allow-none): a #GtkRecentFilter - * - * Sets @filter as the current #GtkRecentFilter object used by @chooser - * to affect the displayed recently used resources. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_set_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - g_return_if_fail (filter == NULL || GTK_IS_RECENT_FILTER (filter)); - - g_object_set (G_OBJECT (chooser), "filter", filter, NULL); -} - -/** - * gtk_recent_chooser_get_filter: - * @chooser: a #GtkRecentChooser - * - * Gets the #GtkRecentFilter object currently used by @chooser to affect - * the display of the recently used resources. - * - * Returns: (transfer none): a #GtkRecentFilter object. - * - * Since: 2.10 - */ -GtkRecentFilter * -gtk_recent_chooser_get_filter (GtkRecentChooser *chooser) -{ - GtkRecentFilter *filter; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - g_object_get (G_OBJECT (chooser), "filter", &filter, NULL); - - /* we need this hack because g_object_get() increases the refcount - * of the returned object; see also gtk_file_chooser_get_filter() - * inside gtkfilechooser.c - */ - if (filter) - g_object_unref (filter); - - return filter; -} - -void -_gtk_recent_chooser_item_activated (GtkRecentChooser *chooser) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_signal_emit (chooser, chooser_signals[ITEM_ACTIVATED], 0); -} - -void -_gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser)); - - g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0); -} diff --git a/gtk/gtkrecentchooser.h b/gtk/gtkrecentchooser.h deleted file mode 100644 index 51f904cb71..0000000000 --- a/gtk/gtkrecentchooser.h +++ /dev/null @@ -1,263 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooser.h - Abstract interface for recent file selectors GUIs - * - * Copyright (C) 2006, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_CHOOSER_H__ -#define __GTK_RECENT_CHOOSER_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_RECENT_CHOOSER (gtk_recent_chooser_get_type ()) -#define GTK_RECENT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER, GtkRecentChooser)) -#define GTK_IS_RECENT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER)) -#define GTK_RECENT_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_RECENT_CHOOSER, GtkRecentChooserIface)) - -/** - * GtkRecentSortType: - * @GTK_RECENT_SORT_NONE: Do not sort the returned list of recently used - * resources. - * @GTK_RECENT_SORT_MRU: Sort the returned list with the most recently used - * items first. - * @GTK_RECENT_SORT_LRU: Sort the returned list with the least recently used - * items first. - * @GTK_RECENT_SORT_CUSTOM: Sort the returned list using a custom sorting - * function passed using gtk_recent_chooser_set_sort_func(). - * - * Used to specify the sorting method to be applyed to the recently - * used resource list. - * - * Since: 2.10 - */ -typedef enum -{ - GTK_RECENT_SORT_NONE = 0, - GTK_RECENT_SORT_MRU, - GTK_RECENT_SORT_LRU, - GTK_RECENT_SORT_CUSTOM -} GtkRecentSortType; - -typedef gint (*GtkRecentSortFunc) (GtkRecentInfo *a, - GtkRecentInfo *b, - gpointer user_data); - - -typedef struct _GtkRecentChooser GtkRecentChooser; /* dummy */ -typedef struct _GtkRecentChooserIface GtkRecentChooserIface; - -/** - * GTK_RECENT_CHOOSER_ERROR: - * - * Used to get the #GError quark for #GtkRecentChooser errors. - * - * Since: 2.10 - */ -#define GTK_RECENT_CHOOSER_ERROR (gtk_recent_chooser_error_quark ()) - -/** - * GtkRecentChooserError: - * @GTK_RECENT_CHOOSER_ERROR_NOT_FOUND: Indicates that a file does not exist - * @GTK_RECENT_CHOOSER_ERROR_INVALID_URI: Indicates a malformed URI - * - * These identify the various errors that can occur while calling - * #GtkRecentChooser functions. - * - * Since: 2.10 - */ -typedef enum -{ - GTK_RECENT_CHOOSER_ERROR_NOT_FOUND, - GTK_RECENT_CHOOSER_ERROR_INVALID_URI -} GtkRecentChooserError; - -GDK_AVAILABLE_IN_ALL -GQuark gtk_recent_chooser_error_quark (void); - - -/** - * GtkRecentChooserIface: - * @set_current_uri: Sets uri as the current URI for chooser. - * @get_current_uri: Gets the URI currently selected by chooser. - * @select_uri: Selects uri inside chooser. - * @unselect_uri: Unselects uri inside chooser. - * @select_all: Selects all the items inside chooser, if the chooser - * supports multiple selection. - * @unselect_all: Unselects all the items inside chooser. - * @get_items: Gets the list of recently used resources in form of - * #GtkRecentInfo objects. - * @get_recent_manager: Gets the #GtkRecentManager used by chooser. - * @add_filter: Adds filter to the list of #GtkRecentFilter objects - * held by chooser. - * @remove_filter: Removes filter from the list of #GtkRecentFilter - * objects held by chooser. - * @list_filters: Gets the #GtkRecentFilter objects held by chooser. - * @set_sort_func: Sets the comparison function used when sorting to - * be sort_func. - * @item_activated: Signal emitted when the user “activates” a recent - * item in the recent chooser. - * @selection_changed: Signal emitted when there is a change in the - * set of selected recently used resources. - */ -struct _GtkRecentChooserIface -{ - /*< private >*/ - GTypeInterface base_iface; - - /*< public >*/ - - /* - * Methods - */ - gboolean (* set_current_uri) (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); - gchar * (* get_current_uri) (GtkRecentChooser *chooser); - gboolean (* select_uri) (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); - void (* unselect_uri) (GtkRecentChooser *chooser, - const gchar *uri); - void (* select_all) (GtkRecentChooser *chooser); - void (* unselect_all) (GtkRecentChooser *chooser); - GList * (* get_items) (GtkRecentChooser *chooser); - GtkRecentManager *(* get_recent_manager) (GtkRecentChooser *chooser); - void (* add_filter) (GtkRecentChooser *chooser, - GtkRecentFilter *filter); - void (* remove_filter) (GtkRecentChooser *chooser, - GtkRecentFilter *filter); - GSList * (* list_filters) (GtkRecentChooser *chooser); - void (* set_sort_func) (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy); - - /* - * Signals - */ - void (* item_activated) (GtkRecentChooser *chooser); - void (* selection_changed) (GtkRecentChooser *chooser); -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_recent_chooser_get_type (void) G_GNUC_CONST; - -/* - * Configuration - */ -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser, - gboolean show_private); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser, - gboolean show_not_found); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser, - gboolean select_multiple); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_limit (GtkRecentChooser *chooser, - gint limit); -GDK_AVAILABLE_IN_ALL -gint gtk_recent_chooser_get_limit (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser, - gboolean local_only); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser, - gboolean show_tips); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser, - gboolean show_icons); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser, - GtkRecentSortType sort_type); -GDK_AVAILABLE_IN_ALL -GtkRecentSortType gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy); - -/* - * Items handling - */ -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -GDK_AVAILABLE_IN_ALL -gchar * gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -GtkRecentInfo *gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_select_all (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -GList * gtk_recent_chooser_get_items (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -gchar ** gtk_recent_chooser_get_uris (GtkRecentChooser *chooser, - gsize *length); - -/* - * Filters - */ -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -GDK_AVAILABLE_IN_ALL -GSList * gtk_recent_chooser_list_filters (GtkRecentChooser *chooser); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_set_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -GDK_AVAILABLE_IN_ALL -GtkRecentFilter *gtk_recent_chooser_get_filter (GtkRecentChooser *chooser); - - -G_END_DECLS - -#endif /* __GTK_RECENT_CHOOSER_H__ */ diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c deleted file mode 100644 index a34642f3a3..0000000000 --- a/gtk/gtkrecentchooserdefault.c +++ /dev/null @@ -1,1707 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooserdefault.c - * Copyright (C) 2005-2006, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "gtkicontheme.h" -#include "gtksettings.h" -#include "gtktreeview.h" -#include "gtkliststore.h" -#include "gtkbutton.h" -#include "gtkcelllayout.h" -#include "gtkcheckmenuitem.h" -#include "gtkcomboboxtext.h" -#include "gtkcssiconthemevalueprivate.h" -#include "gtkdragsource.h" -#include "gtkentry.h" -#include "gtkexpander.h" -#include "gtkframe.h" -#include "gtkbox.h" -#include "gtkpaned.h" -#include "gtkimage.h" -#include "gtkintl.h" -#include "gtklabel.h" -#include "gtkmenuitem.h" -#include "gtkmessagedialog.h" -#include "gtkscrolledwindow.h" -#include "gtkseparatormenuitem.h" -#include "gtksizegroup.h" -#include "gtksizerequest.h" -#include "gtkstylecontextprivate.h" -#include "gtktreemodelsort.h" -#include "gtktreemodelfilter.h" -#include "gtktreeselection.h" -#include "gtktreestore.h" -#include "gtktooltip.h" -#include "gtktypebuiltins.h" -#include "gtkorientable.h" -#include "gtkwindowgroup.h" -#include "gtkgesturemultipress.h" - -#include "gtkrecentmanager.h" -#include "gtkrecentfilter.h" -#include "gtkrecentchooser.h" -#include "gtkrecentchooserprivate.h" -#include "gtkrecentchooserutils.h" -#include "gtkrecentchooserdefault.h" - -typedef struct -{ - GtkRecentManager *manager; - gulong manager_changed_id; - guint local_manager : 1; - - /* RecentChooser properties */ - gint limit; - GtkRecentSortType sort_type; - guint show_private : 1; - guint show_not_found : 1; - guint select_multiple : 1; - guint show_tips : 1; - guint show_icons : 1; - guint local_only : 1; - - guint limit_set : 1; - - GSList *filters; - GtkRecentFilter *current_filter; - GtkWidget *filter_combo_hbox; - GtkWidget *filter_combo; - - GtkRecentSortFunc sort_func; - gpointer sort_data; - GDestroyNotify sort_data_destroy; - - GtkWidget *recent_view; - GtkListStore *recent_store; - GtkTreeViewColumn *icon_column; - GtkTreeViewColumn *meta_column; - GtkCellRenderer *icon_renderer; - GtkCellRenderer *meta_renderer; - GtkTreeSelection *selection; - - GtkWidget *recent_popup_menu; - GtkWidget *recent_popup_menu_copy_item; - GtkWidget *recent_popup_menu_remove_item; - GtkWidget *recent_popup_menu_clear_item; - GtkWidget *recent_popup_menu_show_private_item; - - GtkGesture *multipress_gesture; - - guint load_id; - GList *recent_items; - gint n_recent_items; - gint loaded_items; - guint load_state; -} GtkRecentChooserDefaultPrivate; - -struct _GtkRecentChooserDefault -{ - GtkBox parent_instance; - - GtkRecentChooserDefaultPrivate *priv; -}; - -typedef struct _GtkRecentChooserDefaultClass -{ - GtkBoxClass parent_class; -} GtkRecentChooserDefaultClass; - -/* Keep inline with GtkTreeStore defined in gtkrecentchooserdefault.ui */ -enum { - RECENT_URI_COLUMN, - RECENT_DISPLAY_NAME_COLUMN, - RECENT_INFO_COLUMN, - N_RECENT_COLUMNS -}; - -enum { - LOAD_EMPTY, /* initial state: the model is empty */ - LOAD_PRELOAD, /* the model is loading and not inserted in the tree yet */ - LOAD_LOADING, /* the model is fully loaded but not inserted */ - LOAD_FINISHED /* the model is fully loaded and inserted */ -}; - -#define FALLBACK_ITEM_LIMIT 20 - -#define NUM_CHARS 40 -#define NUM_LINES 9 - -#define DEFAULT_RECENT_FILES_LIMIT 50 - - - -/* GObject */ -static void gtk_recent_chooser_default_finalize (GObject *object); -static void gtk_recent_chooser_default_dispose (GObject *object); -static void gtk_recent_chooser_default_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_recent_chooser_default_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -/* GtkRecentChooserIface */ -static void gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface); -static gboolean gtk_recent_chooser_default_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -static gchar * gtk_recent_chooser_default_get_current_uri (GtkRecentChooser *chooser); -static gboolean gtk_recent_chooser_default_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -static void gtk_recent_chooser_default_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri); -static void gtk_recent_chooser_default_select_all (GtkRecentChooser *chooser); -static void gtk_recent_chooser_default_unselect_all (GtkRecentChooser *chooser); -static GList * gtk_recent_chooser_default_get_items (GtkRecentChooser *chooser); -static GtkRecentManager *gtk_recent_chooser_default_get_recent_manager (GtkRecentChooser *chooser); -static void gtk_recent_chooser_default_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy); -static void gtk_recent_chooser_default_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -static void gtk_recent_chooser_default_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -static GSList * gtk_recent_chooser_default_list_filters (GtkRecentChooser *chooser); - - -static void gtk_recent_chooser_default_map (GtkWidget *widget); - -static void set_current_filter (GtkRecentChooserDefault *impl, - GtkRecentFilter *filter); - -static void reload_recent_items (GtkRecentChooserDefault *impl); -static void chooser_set_model (GtkRecentChooserDefault *impl); - -static void set_recent_manager (GtkRecentChooserDefault *impl, - GtkRecentManager *manager); - -static void chooser_set_sort_type (GtkRecentChooserDefault *impl, - GtkRecentSortType sort_type); - -static void recent_manager_changed_cb (GtkRecentManager *manager, - gpointer user_data); -static void recent_icon_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer user_data); -static void recent_meta_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer user_data); - -static void selection_changed_cb (GtkTreeSelection *z, - gpointer user_data); -static void row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *tree_path, - GtkTreeViewColumn *tree_column, - gpointer user_data); -static void filter_combo_changed_cb (GtkComboBox *combo_box, - gpointer user_data); - -static void remove_all_activated_cb (GtkMenuItem *menu_item, - gpointer user_data); -static void remove_item_activated_cb (GtkMenuItem *menu_item, - gpointer user_data); -static void show_private_toggled_cb (GtkCheckMenuItem *menu_item, - gpointer user_data); - -static void multi_press_cb (GtkGesture *gesture, - int n_press, - double x, - double y, - gpointer user_data); - -static gboolean recent_view_popup_menu_cb (GtkWidget *widget, - gpointer user_data); - -static void recent_view_drag_begin_cb (GtkWidget *widget, - GdkDragContext *context, - gpointer user_data); -static void recent_view_drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint32 time_, - gpointer data); -static gboolean recent_view_query_tooltip_cb (GtkWidget *widget, - gint x, - gint y, - gboolean keyboard_tip, - GtkTooltip *tooltip, - gpointer user_data); - -G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDefault, - _gtk_recent_chooser_default, - GTK_TYPE_BOX, - G_ADD_PRIVATE (GtkRecentChooserDefault) - G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, - gtk_recent_chooser_iface_init)) - -static void -gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface) -{ - iface->set_current_uri = gtk_recent_chooser_default_set_current_uri; - iface->get_current_uri = gtk_recent_chooser_default_get_current_uri; - iface->select_uri = gtk_recent_chooser_default_select_uri; - iface->unselect_uri = gtk_recent_chooser_default_unselect_uri; - iface->select_all = gtk_recent_chooser_default_select_all; - iface->unselect_all = gtk_recent_chooser_default_unselect_all; - iface->get_items = gtk_recent_chooser_default_get_items; - iface->get_recent_manager = gtk_recent_chooser_default_get_recent_manager; - iface->set_sort_func = gtk_recent_chooser_default_set_sort_func; - iface->add_filter = gtk_recent_chooser_default_add_filter; - iface->remove_filter = gtk_recent_chooser_default_remove_filter; - iface->list_filters = gtk_recent_chooser_default_list_filters; -} - -static void -_gtk_recent_chooser_default_class_init (GtkRecentChooserDefaultClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gobject_class->set_property = gtk_recent_chooser_default_set_property; - gobject_class->get_property = gtk_recent_chooser_default_get_property; - gobject_class->dispose = gtk_recent_chooser_default_dispose; - gobject_class->finalize = gtk_recent_chooser_default_finalize; - - widget_class->map = gtk_recent_chooser_default_map; - - _gtk_recent_chooser_install_properties (gobject_class); - - /* Bind class to template - */ - gtk_widget_class_set_template_from_resource (widget_class, - "/org/gtk/libgtk/ui/gtkrecentchooserdefault.ui"); - - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, filter_combo_hbox); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, filter_combo); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, recent_view); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, recent_store); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, icon_column); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, meta_column); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, icon_renderer); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, meta_renderer); - gtk_widget_class_bind_template_child_private (widget_class, GtkRecentChooserDefault, selection); - - gtk_widget_class_bind_template_callback (widget_class, selection_changed_cb); - gtk_widget_class_bind_template_callback (widget_class, row_activated_cb); - gtk_widget_class_bind_template_callback (widget_class, filter_combo_changed_cb); - gtk_widget_class_bind_template_callback (widget_class, recent_view_popup_menu_cb); - gtk_widget_class_bind_template_callback (widget_class, recent_view_drag_begin_cb); - gtk_widget_class_bind_template_callback (widget_class, recent_view_drag_data_get_cb); - gtk_widget_class_bind_template_callback (widget_class, recent_view_query_tooltip_cb); -} - -static void -_gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl) -{ - GtkRecentChooserDefaultPrivate *priv; - - impl->priv = priv = _gtk_recent_chooser_default_get_instance_private (impl); - - /* by default, we use the global manager */ - priv->local_manager = FALSE; - - priv->limit = FALLBACK_ITEM_LIMIT; - priv->sort_type = GTK_RECENT_SORT_NONE; - - priv->show_icons = TRUE; - priv->show_private = FALSE; - priv->show_not_found = TRUE; - priv->show_tips = FALSE; - priv->select_multiple = FALSE; - priv->local_only = TRUE; - - priv->current_filter = NULL; - - priv->recent_items = NULL; - priv->n_recent_items = 0; - priv->loaded_items = 0; - - priv->load_state = LOAD_EMPTY; - - gtk_widget_init_template (GTK_WIDGET (impl)); - - g_object_set_data (G_OBJECT (priv->recent_view), - "GtkRecentChooserDefault", impl); - - gtk_tree_view_column_set_cell_data_func (priv->icon_column, - priv->icon_renderer, - recent_icon_data_func, - impl, - NULL); - gtk_tree_view_column_set_cell_data_func (priv->meta_column, - priv->meta_renderer, - recent_meta_data_func, - impl, - NULL); - gtk_drag_source_set (priv->recent_view, - GDK_BUTTON1_MASK, - NULL, - GDK_ACTION_COPY); - gtk_drag_source_add_uri_targets (priv->recent_view); - - priv->multipress_gesture = gtk_gesture_multi_press_new (priv->recent_view); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), GDK_BUTTON_SECONDARY); - g_signal_connect (priv->multipress_gesture, "pressed", - G_CALLBACK (multi_press_cb), impl); -} - -static void -gtk_recent_chooser_default_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (object); - - switch (prop_id) - { - case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER: - set_recent_manager (impl, g_value_get_object (value)); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE: - if (impl->priv->show_private != g_value_get_boolean (value)) - { - impl->priv->show_private = g_value_get_boolean (value); - if (impl->priv->recent_popup_menu_show_private_item) - { - GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (impl->priv->recent_popup_menu_show_private_item); - g_signal_handlers_block_by_func (item, G_CALLBACK (show_private_toggled_cb), impl); - gtk_check_menu_item_set_active (item, impl->priv->show_private); - g_signal_handlers_unblock_by_func (item, G_CALLBACK (show_private_toggled_cb), impl); - } - reload_recent_items (impl); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND: - if (impl->priv->show_not_found != g_value_get_boolean (value)) - { - impl->priv->show_not_found = g_value_get_boolean (value); - reload_recent_items (impl); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS: - if (impl->priv->show_tips != g_value_get_boolean (value)) - { - impl->priv->show_tips = g_value_get_boolean (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS: - if (impl->priv->show_icons != g_value_get_boolean (value)) - { - impl->priv->show_icons = g_value_get_boolean (value); - gtk_tree_view_column_set_visible (impl->priv->icon_column, impl->priv->show_icons); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE: - if (impl->priv->select_multiple != g_value_get_boolean (value)) - { - impl->priv->select_multiple = g_value_get_boolean (value); - if (impl->priv->select_multiple) - gtk_tree_selection_set_mode (impl->priv->selection, GTK_SELECTION_MULTIPLE); - else - gtk_tree_selection_set_mode (impl->priv->selection, GTK_SELECTION_SINGLE); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY: - if (impl->priv->local_only != g_value_get_boolean (value)) - { - impl->priv->local_only = g_value_get_boolean (value); - reload_recent_items (impl); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_LIMIT: - if (impl->priv->limit != g_value_get_int (value)) - { - impl->priv->limit = g_value_get_int (value); - impl->priv->limit_set = TRUE; - reload_recent_items (impl); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SORT_TYPE: - chooser_set_sort_type (impl, g_value_get_enum (value)); - break; - case GTK_RECENT_CHOOSER_PROP_FILTER: - set_current_filter (impl, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_recent_chooser_default_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (object); - - switch (prop_id) - { - case GTK_RECENT_CHOOSER_PROP_LIMIT: - g_value_set_int (value, impl->priv->limit); - break; - case GTK_RECENT_CHOOSER_PROP_SORT_TYPE: - g_value_set_enum (value, impl->priv->sort_type); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE: - g_value_set_boolean (value, impl->priv->show_private); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS: - g_value_set_boolean (value, impl->priv->show_icons); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND: - g_value_set_boolean (value, impl->priv->show_not_found); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS: - g_value_set_boolean (value, impl->priv->show_tips); - break; - case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY: - g_value_set_boolean (value, impl->priv->local_only); - break; - case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE: - g_value_set_boolean (value, impl->priv->select_multiple); - break; - case GTK_RECENT_CHOOSER_PROP_FILTER: - g_value_set_object (value, impl->priv->current_filter); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_recent_chooser_default_dispose (GObject *object) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (object); - - if (impl->priv->load_id) - { - g_source_remove (impl->priv->load_id); - impl->priv->load_state = LOAD_EMPTY; - impl->priv->load_id = 0; - } - - g_list_free_full (impl->priv->recent_items, (GDestroyNotify) gtk_recent_info_unref); - impl->priv->recent_items = NULL; - - if (impl->priv->manager && impl->priv->manager_changed_id) - { - g_signal_handler_disconnect (impl->priv->manager, impl->priv->manager_changed_id); - impl->priv->manager_changed_id = 0; - } - - if (impl->priv->filters) - { - g_slist_free_full (impl->priv->filters, g_object_unref); - impl->priv->filters = NULL; - } - - if (impl->priv->current_filter) - { - g_object_unref (impl->priv->current_filter); - impl->priv->current_filter = NULL; - } - - G_OBJECT_CLASS (_gtk_recent_chooser_default_parent_class)->dispose (object); -} - -static void -gtk_recent_chooser_default_finalize (GObject *object) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (object); - - impl->priv->manager = NULL; - - if (impl->priv->sort_data_destroy) - { - impl->priv->sort_data_destroy (impl->priv->sort_data); - impl->priv->sort_data_destroy = NULL; - } - - g_object_unref (impl->priv->multipress_gesture); - - impl->priv->sort_data = NULL; - impl->priv->sort_func = NULL; - - G_OBJECT_CLASS (_gtk_recent_chooser_default_parent_class)->finalize (object); -} - -/* Shows an error dialog set as transient for the specified window */ -static void -error_message_with_parent (GtkWindow *parent, - const gchar *msg, - const gchar *detail) -{ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "%s", - msg); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", detail); - - if (gtk_window_has_group (parent)) - gtk_window_group_add_window (gtk_window_get_group (parent), - GTK_WINDOW (dialog)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -/* Returns a toplevel GtkWindow, or NULL if none */ -static GtkWindow * -get_toplevel (GtkWidget *widget) -{ - GtkWidget *toplevel; - - toplevel = gtk_widget_get_toplevel (widget); - if (!gtk_widget_is_toplevel (toplevel)) - return NULL; - else - return GTK_WINDOW (toplevel); -} - -/* Shows an error dialog for the file chooser */ -static void -error_message (GtkRecentChooserDefault *impl, - const gchar *msg, - const gchar *detail) -{ - error_message_with_parent (get_toplevel (GTK_WIDGET (impl)), msg, detail); -} - -static void -set_busy_cursor (GtkRecentChooserDefault *impl, - gboolean busy) -{ - GtkWindow *toplevel; - - toplevel = get_toplevel (GTK_WIDGET (impl)); - if (!toplevel || !gtk_widget_get_realized (GTK_WIDGET (toplevel))) - return; - - if (busy) - gtk_widget_set_cursor_from_name (GTK_WIDGET (toplevel), "progress"); - else - gtk_widget_set_cursor (GTK_WIDGET (toplevel), NULL); -} - -static void -chooser_set_model (GtkRecentChooserDefault *impl) -{ - g_assert (impl->priv->recent_store != NULL); - g_assert (impl->priv->load_state == LOAD_LOADING); - - gtk_tree_view_set_model (GTK_TREE_VIEW (impl->priv->recent_view), - GTK_TREE_MODEL (impl->priv->recent_store)); - gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->priv->recent_view)); - gtk_tree_view_set_enable_search (GTK_TREE_VIEW (impl->priv->recent_view), TRUE); - gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->priv->recent_view), - RECENT_DISPLAY_NAME_COLUMN); - - impl->priv->load_state = LOAD_FINISHED; -} - -static gboolean -load_recent_items (gpointer user_data) -{ - GtkRecentChooserDefault *impl; - GtkRecentInfo *info; - GtkTreeIter iter; - const gchar *uri, *name; - gboolean retval; - - impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - - g_assert ((impl->priv->load_state == LOAD_EMPTY) || - (impl->priv->load_state == LOAD_PRELOAD)); - - /* store the items for multiple runs */ - if (!impl->priv->recent_items) - { - impl->priv->recent_items = gtk_recent_chooser_get_items (GTK_RECENT_CHOOSER (impl)); - if (!impl->priv->recent_items) - { - impl->priv->load_state = LOAD_FINISHED; - impl->priv->load_id = 0; - return FALSE; - } - - impl->priv->n_recent_items = g_list_length (impl->priv->recent_items); - impl->priv->loaded_items = 0; - impl->priv->load_state = LOAD_PRELOAD; - } - - info = (GtkRecentInfo *) g_list_nth_data (impl->priv->recent_items, - impl->priv->loaded_items); - g_assert (info); - - uri = gtk_recent_info_get_uri (info); - name = gtk_recent_info_get_display_name (info); - - /* at this point, everything goes inside the model; operations on the - * visualization of items inside the model are done in the cell data - * funcs (remember that there are two of those: one for the icon and - * one for the text), while the filtering is done only when a filter - * is actually loaded. */ - gtk_list_store_append (impl->priv->recent_store, &iter); - gtk_list_store_set (impl->priv->recent_store, &iter, - RECENT_URI_COLUMN, uri, /* uri */ - RECENT_DISPLAY_NAME_COLUMN, name, /* display_name */ - RECENT_INFO_COLUMN, info, /* info */ - -1); - - impl->priv->loaded_items += 1; - - if (impl->priv->loaded_items == impl->priv->n_recent_items) - { - /* we have finished loading, so we remove the items cache */ - impl->priv->load_state = LOAD_LOADING; - - g_list_free_full (impl->priv->recent_items, (GDestroyNotify) gtk_recent_info_unref); - - impl->priv->recent_items = NULL; - impl->priv->n_recent_items = 0; - impl->priv->loaded_items = 0; - - /* load the filled up model */ - chooser_set_model (impl); - - retval = FALSE; - impl->priv->load_id = 0; - } - else - { - /* we did not finish, so continue loading */ - retval = TRUE; - } - - return retval; -} - -static void -cleanup_after_load (gpointer user_data) -{ - GtkRecentChooserDefault *impl; - - impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - - if (impl->priv->load_id != 0) - { - g_assert ((impl->priv->load_state == LOAD_EMPTY) || - (impl->priv->load_state == LOAD_PRELOAD) || - (impl->priv->load_state == LOAD_LOADING) || - (impl->priv->load_state == LOAD_FINISHED)); - - /* we have officialy finished loading all the items, - * so we can reset the state machine - */ - impl->priv->load_id = 0; - impl->priv->load_state = LOAD_EMPTY; - } - else - g_assert ((impl->priv->load_state == LOAD_EMPTY) || - (impl->priv->load_state == LOAD_LOADING) || - (impl->priv->load_state == LOAD_FINISHED)); - - set_busy_cursor (impl, FALSE); -} - -/* clears the current model and reloads the recently used resources */ -static void -reload_recent_items (GtkRecentChooserDefault *impl) -{ - /* reload is already in progress - do not disturb */ - if (impl->priv->load_id) - return; - - gtk_tree_view_set_model (GTK_TREE_VIEW (impl->priv->recent_view), NULL); - gtk_list_store_clear (impl->priv->recent_store); - - if (!impl->priv->limit_set) - impl->priv->limit = DEFAULT_RECENT_FILES_LIMIT; - - set_busy_cursor (impl, TRUE); - - impl->priv->load_state = LOAD_EMPTY; - impl->priv->load_id = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 30, - load_recent_items, - impl, - cleanup_after_load); - g_source_set_name_by_id (impl->priv->load_id, "[gtk+] load_recent_items"); -} - -/* taken form gtkfilechooserdialog.c */ -static void -set_default_size (GtkRecentChooserDefault *impl) -{ - GtkScrolledWindow *scrollw; - GtkWidget *widget; - gint width, height; - double font_size; - GdkDisplay *display; - GdkMonitor *monitor; - GtkRequisition req; - GdkRectangle workarea; - GtkStyleContext *context; - - widget = GTK_WIDGET (impl); - context = gtk_widget_get_style_context (widget); - - /* Size based on characters and the icon size */ - gtk_style_context_get (context, "font-size", &font_size, NULL); - - width = 16 + font_size * NUM_CHARS + 0.5; - height = (16 + font_size) * NUM_LINES + 0.5; - - /* Use at least the requisition size... */ - gtk_widget_get_preferred_size (widget, &req, NULL); - width = MAX (width, req.width); - height = MAX (height, req.height); - - /* ... but no larger than the monitor */ - display = gtk_widget_get_display (widget); - monitor = gdk_display_get_monitor_at_window (display, gtk_widget_get_window (widget)); - gdk_monitor_get_workarea (monitor, &workarea); - - width = MIN (width, workarea.width * 3 / 4); - height = MIN (height, workarea.height * 3 / 4); - - /* Set size */ - scrollw = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (impl->priv->recent_view)); - gtk_scrolled_window_set_min_content_width (scrollw, width); - gtk_scrolled_window_set_min_content_height (scrollw, height); -} - -static void -gtk_recent_chooser_default_map (GtkWidget *widget) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (widget); - - GTK_WIDGET_CLASS (_gtk_recent_chooser_default_parent_class)->map (widget); - - /* reloads everything */ - reload_recent_items (impl); - - set_default_size (impl); -} - -static void -recent_icon_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkRecentInfo *info = NULL; - GIcon *icon; - - gtk_tree_model_get (model, iter, RECENT_INFO_COLUMN, &info, -1); - g_assert (info != NULL); - - icon = gtk_recent_info_get_gicon (info); - g_object_set (cell, "gicon", icon, NULL); - - if (icon != NULL) - g_object_unref (icon); - - gtk_recent_info_unref (info); -} - -static void -recent_meta_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkRecentInfo *info = NULL; - gchar *name; - - gtk_tree_model_get (model, iter, - RECENT_DISPLAY_NAME_COLUMN, &name, - RECENT_INFO_COLUMN, &info, - -1); - g_assert (info != NULL); - - if (!name) - name = gtk_recent_info_get_short_name (info); - - g_object_set (cell, "text", name, NULL); - - g_free (name); - gtk_recent_info_unref (info); -} - - -static gchar * -gtk_recent_chooser_default_get_current_uri (GtkRecentChooser *chooser) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - g_assert (impl->priv->selection != NULL); - - if (!impl->priv->select_multiple) - { - GtkTreeModel *model; - GtkTreeIter iter; - gchar *uri = NULL; - - if (!gtk_tree_selection_get_selected (impl->priv->selection, &model, &iter)) - return NULL; - - gtk_tree_model_get (model, &iter, RECENT_URI_COLUMN, &uri, -1); - - return uri; - } - - return NULL; -} - -typedef struct -{ - guint found : 1; - guint do_select : 1; - guint do_activate : 1; - - gchar *uri; - - GtkRecentChooserDefault *impl; -} SelectURIData; - -static gboolean -scan_for_uri_cb (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - SelectURIData *select_data = (SelectURIData *) user_data; - gchar *uri = NULL; - - if (!select_data) - return TRUE; - - if (select_data->found) - return TRUE; - - gtk_tree_model_get (model, iter, RECENT_URI_COLUMN, &uri, -1); - if (!uri) - return FALSE; - - if (strcmp (uri, select_data->uri) == 0) - { - select_data->found = TRUE; - - if (select_data->do_activate) - gtk_tree_view_row_activated (GTK_TREE_VIEW (select_data->impl->priv->recent_view), - path, - select_data->impl->priv->meta_column); - - if (select_data->do_select) - gtk_tree_selection_select_path (select_data->impl->priv->selection, path); - else - gtk_tree_selection_unselect_path (select_data->impl->priv->selection, path); - - g_free (uri); - - return TRUE; - } - - g_free (uri); - - return FALSE; -} - -static gboolean -gtk_recent_chooser_default_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - SelectURIData *data; - - data = g_new0 (SelectURIData, 1); - data->uri = g_strdup (uri); - data->impl = impl; - data->found = FALSE; - data->do_activate = TRUE; - data->do_select = TRUE; - - gtk_tree_model_foreach (GTK_TREE_MODEL (impl->priv->recent_store), - scan_for_uri_cb, - data); - - if (!data->found) - { - g_free (data->uri); - g_free (data); - - g_set_error (error, GTK_RECENT_CHOOSER_ERROR, - GTK_RECENT_CHOOSER_ERROR_NOT_FOUND, - _("No item for URI “%s” found"), - uri); - return FALSE; - } - - g_free (data->uri); - g_free (data); - - return TRUE; -} - -static gboolean -gtk_recent_chooser_default_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - SelectURIData *data; - - data = g_new0 (SelectURIData, 1); - data->uri = g_strdup (uri); - data->impl = impl; - data->found = FALSE; - data->do_activate = FALSE; - data->do_select = TRUE; - - gtk_tree_model_foreach (GTK_TREE_MODEL (impl->priv->recent_store), - scan_for_uri_cb, - data); - - if (!data->found) - { - g_free (data->uri); - g_free (data); - - g_set_error (error, GTK_RECENT_CHOOSER_ERROR, - GTK_RECENT_CHOOSER_ERROR_NOT_FOUND, - _("No item for URI “%s” found"), - uri); - return FALSE; - } - - g_free (data->uri); - g_free (data); - - return TRUE; -} - -static void -gtk_recent_chooser_default_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - SelectURIData *data; - - data = g_new0 (SelectURIData, 1); - data->uri = g_strdup (uri); - data->impl = impl; - data->found = FALSE; - data->do_activate = FALSE; - data->do_select = FALSE; - - gtk_tree_model_foreach (GTK_TREE_MODEL (impl->priv->recent_store), - scan_for_uri_cb, - data); - - g_free (data->uri); - g_free (data); -} - -static void -gtk_recent_chooser_default_select_all (GtkRecentChooser *chooser) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - if (!impl->priv->select_multiple) - return; - - gtk_tree_selection_select_all (impl->priv->selection); -} - -static void -gtk_recent_chooser_default_unselect_all (GtkRecentChooser *chooser) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - gtk_tree_selection_unselect_all (impl->priv->selection); -} - -static void -gtk_recent_chooser_default_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - if (impl->priv->sort_data_destroy) - { - impl->priv->sort_data_destroy (impl->priv->sort_data); - impl->priv->sort_data_destroy = NULL; - } - - impl->priv->sort_func = NULL; - impl->priv->sort_data = NULL; - - if (sort_func) - { - impl->priv->sort_func = sort_func; - impl->priv->sort_data = sort_data; - impl->priv->sort_data_destroy = data_destroy; - } -} - -static GList * -gtk_recent_chooser_default_get_items (GtkRecentChooser *chooser) -{ - GtkRecentChooserDefault *impl; - - impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - return _gtk_recent_chooser_get_items (chooser, - impl->priv->current_filter, - impl->priv->sort_func, - impl->priv->sort_data); -} - -static GtkRecentManager * -gtk_recent_chooser_default_get_recent_manager (GtkRecentChooser *chooser) -{ - return GTK_RECENT_CHOOSER_DEFAULT (chooser)->priv->manager; -} - -static void -show_filters (GtkRecentChooserDefault *impl, - gboolean show) -{ - if (show) - gtk_widget_show (impl->priv->filter_combo_hbox); - else - gtk_widget_hide (impl->priv->filter_combo_hbox); -} - -static void -gtk_recent_chooser_default_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - GtkRecentChooserDefault *impl; - const gchar *name; - - impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - if (g_slist_find (impl->priv->filters, filter)) - { - g_warning ("gtk_recent_chooser_add_filter() called on filter already in list"); - return; - } - - g_object_ref_sink (filter); - impl->priv->filters = g_slist_append (impl->priv->filters, filter); - - /* display new filter */ - name = gtk_recent_filter_get_name (filter); - if (!name) - name = _("Untitled filter"); - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (impl->priv->filter_combo), name); - - if (!g_slist_find (impl->priv->filters, impl->priv->current_filter)) - set_current_filter (impl, filter); - - show_filters (impl, TRUE); -} - -static void -gtk_recent_chooser_default_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - GtkTreeModel *model; - GtkTreeIter iter; - gint filter_idx; - - filter_idx = g_slist_index (impl->priv->filters, filter); - - if (filter_idx < 0) - { - g_warning ("gtk_recent_chooser_remove_filter() called on filter not in list"); - return; - } - - impl->priv->filters = g_slist_remove (impl->priv->filters, filter); - - if (filter == impl->priv->current_filter) - { - if (impl->priv->filters) - set_current_filter (impl, impl->priv->filters->data); - else - set_current_filter (impl, NULL); - } - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (impl->priv->filter_combo)); - gtk_tree_model_iter_nth_child (model, &iter, NULL, filter_idx); - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - - g_object_unref (filter); - - if (!impl->priv->filters) - show_filters (impl, FALSE); -} - -static GSList * -gtk_recent_chooser_default_list_filters (GtkRecentChooser *chooser) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser); - - return g_slist_copy (impl->priv->filters); -} - -static void -set_current_filter (GtkRecentChooserDefault *impl, - GtkRecentFilter *filter) -{ - if (impl->priv->current_filter != filter) - { - gint filter_idx; - - filter_idx = g_slist_index (impl->priv->filters, filter); - if (impl->priv->filters && filter && filter_idx < 0) - return; - - if (impl->priv->current_filter) - g_object_unref (impl->priv->current_filter); - - impl->priv->current_filter = filter; - - if (impl->priv->current_filter) - { - g_object_ref_sink (impl->priv->current_filter); - } - - if (impl->priv->filters) - gtk_combo_box_set_active (GTK_COMBO_BOX (impl->priv->filter_combo), - filter_idx); - - if (impl->priv->recent_store) - reload_recent_items (impl); - - g_object_notify (G_OBJECT (impl), "filter"); - } -} - -static void -chooser_set_sort_type (GtkRecentChooserDefault *impl, - GtkRecentSortType sort_type) -{ - if (impl->priv->sort_type != sort_type) - { - impl->priv->sort_type = sort_type; - reload_recent_items (impl); - g_object_notify (G_OBJECT (impl), "sort-type"); - } -} - -static void -recent_manager_changed_cb (GtkRecentManager *manager, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - - reload_recent_items (impl); -} - -static void -selection_changed_cb (GtkTreeSelection *selection, - gpointer user_data) -{ - _gtk_recent_chooser_selection_changed (GTK_RECENT_CHOOSER (user_data)); -} - -static void -row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *tree_path, - GtkTreeViewColumn *tree_column, - gpointer user_data) -{ - _gtk_recent_chooser_item_activated (GTK_RECENT_CHOOSER (user_data)); -} - -static void -filter_combo_changed_cb (GtkComboBox *combo_box, - gpointer user_data) -{ - GtkRecentChooserDefault *impl; - gint new_index; - GtkRecentFilter *filter; - - impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - - new_index = gtk_combo_box_get_active (combo_box); - filter = g_slist_nth_data (impl->priv->filters, new_index); - - set_current_filter (impl, filter); -} - -static GIcon * -get_drag_icon (GtkRecentChooserDefault *impl) -{ - GtkRecentInfo *info; - GIcon *gicon = NULL; - - g_assert (GTK_IS_RECENT_CHOOSER_DEFAULT (impl)); - - info = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (impl)); - if (info != NULL) - { - gicon = gtk_recent_info_get_gicon (info); - gtk_recent_info_unref (info); - } - - return gicon; -} - -static void -recent_view_drag_begin_cb (GtkWidget *widget, - GdkDragContext *context, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - GIcon *icon; - - icon = get_drag_icon (impl); - if (icon) - { - gtk_drag_set_icon_gicon (context, icon, 0, 0); - g_object_unref (icon); - } - else - gtk_drag_set_icon_default (context); -} - -typedef struct -{ - gchar **uri_list; - gsize next_pos; -} DragData; - -static void -append_uri_to_urilist (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - DragData *drag_data = (DragData *) user_data; - gchar *uri = NULL; - gsize pos; - - gtk_tree_model_get (model, iter, - RECENT_URI_COLUMN, &uri, - -1); - g_assert (uri != NULL); - - pos = drag_data->next_pos; - drag_data->uri_list[pos] = g_strdup (uri); - drag_data->next_pos = pos + 1; -} - -static void -recent_view_drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint32 time_, - gpointer data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (data); - DragData drag_data; - gsize n_uris; - - n_uris = gtk_tree_selection_count_selected_rows (impl->priv->selection); - if (n_uris == 0) - return; - - drag_data.uri_list = g_new0 (gchar *, n_uris + 1); - drag_data.next_pos = 0; - - gtk_tree_selection_selected_foreach (impl->priv->selection, - append_uri_to_urilist, - &drag_data); - - gtk_selection_data_set_uris (selection_data, drag_data.uri_list); - - g_strfreev (drag_data.uri_list); -} - -static gboolean -recent_view_query_tooltip_cb (GtkWidget *widget, - gint x, - gint y, - gboolean keyboard_tip, - GtkTooltip *tooltip, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = user_data; - GtkTreeView *tree_view; - GtkTreeIter iter; - GtkTreePath *path = NULL; - GtkRecentInfo *info = NULL; - gchar *uri_display; - - if (!impl->priv->show_tips) - return FALSE; - - tree_view = GTK_TREE_VIEW (impl->priv->recent_view); - - gtk_tree_view_get_tooltip_context (tree_view, - &x, &y, - keyboard_tip, - NULL, &path, NULL); - if (!path) - return FALSE; - - if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->priv->recent_store), &iter, path)) - { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (GTK_TREE_MODEL (impl->priv->recent_store), &iter, - RECENT_INFO_COLUMN, &info, - -1); - - uri_display = gtk_recent_info_get_uri_display (info); - - gtk_tooltip_set_text (tooltip, uri_display); - gtk_tree_view_set_tooltip_row (tree_view, tooltip, path); - - g_free (uri_display); - gtk_tree_path_free (path); - gtk_recent_info_unref (info); - - return TRUE; -} - -static void -remove_selected_from_list (GtkRecentChooserDefault *impl) -{ - gchar *uri; - GError *err; - - if (impl->priv->select_multiple) - return; - - uri = gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (impl)); - if (!uri) - return; - - err = NULL; - if (!gtk_recent_manager_remove_item (impl->priv->manager, uri, &err)) - { - gchar *msg; - - msg = g_strdup (_("Could not remove item")); - error_message (impl, msg, err->message); - - g_free (msg); - g_error_free (err); - } - - g_free (uri); -} - -static void -copy_activated_cb (GtkMenuItem *menu_item, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - GtkRecentInfo *info; - gchar *utf8_uri; - - info = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (impl)); - if (!info) - return; - - utf8_uri = gtk_recent_info_get_uri_display (info); - - gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (impl)), - utf8_uri); - - gtk_recent_info_unref (info); - g_free (utf8_uri); -} - -static void -remove_all_activated_cb (GtkMenuItem *menu_item, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - GError *err = NULL; - - gtk_recent_manager_purge_items (impl->priv->manager, &err); - if (err) - { - gchar *msg; - - msg = g_strdup (_("Could not clear list")); - - error_message (impl, msg, err->message); - - g_free (msg); - g_error_free (err); - } -} - -static void -remove_item_activated_cb (GtkMenuItem *menu_item, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - - remove_selected_from_list (impl); -} - -static void -show_private_toggled_cb (GtkCheckMenuItem *menu_item, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - - g_object_set (G_OBJECT (impl), - "show-private", gtk_check_menu_item_get_active (menu_item), - NULL); -} - -static void -recent_popup_menu_detach_cb (GtkWidget *attach_widget, - GtkMenu *menu) -{ - GtkRecentChooserDefault *impl; - - impl = g_object_get_data (G_OBJECT (attach_widget), "GtkRecentChooserDefault"); - g_assert (GTK_IS_RECENT_CHOOSER_DEFAULT (impl)); - - impl->priv->recent_popup_menu = NULL; - impl->priv->recent_popup_menu_remove_item = NULL; - impl->priv->recent_popup_menu_copy_item = NULL; - impl->priv->recent_popup_menu_clear_item = NULL; - impl->priv->recent_popup_menu_show_private_item = NULL; -} - -static void -recent_view_menu_ensure_state (GtkRecentChooserDefault *impl) -{ - gint count; - - g_assert (GTK_IS_RECENT_CHOOSER_DEFAULT (impl)); - g_assert (impl->priv->recent_popup_menu != NULL); - - if (!impl->priv->manager) - count = 0; - else - g_object_get (G_OBJECT (impl->priv->manager), "size", &count, NULL); - - if (count == 0) - { - gtk_widget_set_sensitive (impl->priv->recent_popup_menu_remove_item, FALSE); - gtk_widget_set_sensitive (impl->priv->recent_popup_menu_copy_item, FALSE); - gtk_widget_set_sensitive (impl->priv->recent_popup_menu_clear_item, FALSE); - gtk_widget_set_sensitive (impl->priv->recent_popup_menu_show_private_item, FALSE); - } -} - -static void -recent_view_menu_build (GtkRecentChooserDefault *impl) -{ - GtkWidget *item; - - if (impl->priv->recent_popup_menu) - { - recent_view_menu_ensure_state (impl); - - return; - } - - impl->priv->recent_popup_menu = gtk_menu_new (); - gtk_menu_attach_to_widget (GTK_MENU (impl->priv->recent_popup_menu), - impl->priv->recent_view, - recent_popup_menu_detach_cb); - - item = gtk_menu_item_new_with_mnemonic (_("Copy _Location")); - impl->priv->recent_popup_menu_copy_item = item; - g_signal_connect (item, "activate", - G_CALLBACK (copy_activated_cb), impl); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (impl->priv->recent_popup_menu), item); - - item = gtk_separator_menu_item_new (); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (impl->priv->recent_popup_menu), item); - - item = gtk_menu_item_new_with_mnemonic (_("_Remove From List")); - impl->priv->recent_popup_menu_remove_item = item; - g_signal_connect (item, "activate", - G_CALLBACK (remove_item_activated_cb), impl); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (impl->priv->recent_popup_menu), item); - - item = gtk_menu_item_new_with_mnemonic (_("_Clear List")); - impl->priv->recent_popup_menu_clear_item = item; - g_signal_connect (item, "activate", - G_CALLBACK (remove_all_activated_cb), impl); - - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (impl->priv->recent_popup_menu), item); - - item = gtk_separator_menu_item_new (); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (impl->priv->recent_popup_menu), item); - - item = gtk_check_menu_item_new_with_mnemonic (_("Show _Private Resources")); - impl->priv->recent_popup_menu_show_private_item = item; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), impl->priv->show_private); - g_signal_connect (item, "toggled", - G_CALLBACK (show_private_toggled_cb), impl); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (impl->priv->recent_popup_menu), item); - - recent_view_menu_ensure_state (impl); -} - -static void -recent_view_menu_popup (GtkRecentChooserDefault *impl, - GdkEventButton *event) -{ - recent_view_menu_build (impl); - - if (event && gdk_event_triggers_context_menu ((GdkEvent *) event)) - gtk_menu_popup_at_pointer (GTK_MENU (impl->priv->recent_popup_menu), (GdkEvent *) event); - else - { - gtk_menu_popup_at_widget (GTK_MENU (impl->priv->recent_popup_menu), - impl->priv->recent_view, - GDK_GRAVITY_CENTER, - GDK_GRAVITY_CENTER, - (GdkEvent *) event); - - gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->priv->recent_popup_menu), FALSE); - } -} - -static gboolean -recent_view_popup_menu_cb (GtkWidget *widget, - gpointer user_data) -{ - recent_view_menu_popup (GTK_RECENT_CHOOSER_DEFAULT (user_data), NULL); - return TRUE; -} - -static void -multi_press_cb (GtkGesture *gesture, - int n_press, - double x, - double y, - gpointer user_data) -{ - GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data); - GtkTreePath *path; - GdkEventSequence *sequence; - const GdkEvent *event; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (impl->priv->recent_view), - x, y, &path, - NULL, NULL, NULL)) - return; - - /* select the path before creating the popup menu */ - gtk_tree_selection_select_path (impl->priv->selection, path); - gtk_tree_path_free (path); - - sequence = gtk_gesture_get_last_updated_sequence (gesture); - event = gtk_gesture_get_last_event (gesture, sequence); - - recent_view_menu_popup (impl, (GdkEventButton *)event); -} - -static void -set_recent_manager (GtkRecentChooserDefault *impl, - GtkRecentManager *manager) -{ - if (impl->priv->manager) - { - if (impl->priv->manager_changed_id) - { - g_signal_handler_disconnect (impl, impl->priv->manager_changed_id); - impl->priv->manager_changed_id = 0; - } - - impl->priv->manager = NULL; - } - - if (manager) - impl->priv->manager = manager; - else - impl->priv->manager = gtk_recent_manager_get_default (); - - if (impl->priv->manager) - { - impl->priv->manager_changed_id = g_signal_connect (impl->priv->manager, "changed", - G_CALLBACK (recent_manager_changed_cb), - impl); - } -} - -GtkWidget * -_gtk_recent_chooser_default_new (GtkRecentManager *manager) -{ - return g_object_new (GTK_TYPE_RECENT_CHOOSER_DEFAULT, - "recent-manager", manager, - NULL); -} diff --git a/gtk/gtkrecentchooserdefault.h b/gtk/gtkrecentchooserdefault.h deleted file mode 100644 index cbff1d96a5..0000000000 --- a/gtk/gtkrecentchooserdefault.h +++ /dev/null @@ -1,40 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooserdefault.h - * Copyright (C) 2006 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_CHOOSER_DEFAULT_H__ -#define __GTK_RECENT_CHOOSER_DEFAULT_H__ - -#include - -G_BEGIN_DECLS - - -#define GTK_TYPE_RECENT_CHOOSER_DEFAULT (_gtk_recent_chooser_default_get_type ()) -#define GTK_RECENT_CHOOSER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_DEFAULT, GtkRecentChooserDefault)) -#define GTK_IS_RECENT_CHOOSER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_DEFAULT)) - - -typedef struct _GtkRecentChooserDefault GtkRecentChooserDefault; - -GType _gtk_recent_chooser_default_get_type (void) G_GNUC_CONST; -GtkWidget *_gtk_recent_chooser_default_new (GtkRecentManager *recent_manager); - - -G_END_DECLS - -#endif /* __GTK_RECENT_CHOOSER_DEFAULT_H__ */ diff --git a/gtk/gtkrecentchooserdialog.c b/gtk/gtkrecentchooserdialog.c deleted file mode 100644 index beeae9102b..0000000000 --- a/gtk/gtkrecentchooserdialog.c +++ /dev/null @@ -1,360 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooserdialog.c: Recent files selector dialog - * Copyright (C) 2006 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include "gtkrecentchooserdialog.h" -#include "gtkrecentchooserwidget.h" -#include "gtkrecentchooserutils.h" -#include "gtkrecentmanager.h" -#include "gtktypebuiltins.h" -#include "gtksettings.h" -#include "gtkdialogprivate.h" -#include "gtkbox.h" - -#include - - -/** - * SECTION:gtkrecentchooserdialog - * @Short_description: Displays recently used files in a dialog - * @Title: GtkRecentChooserDialog - * @See_also:#GtkRecentChooser, #GtkDialog - * - * #GtkRecentChooserDialog is a dialog box suitable for displaying the recently - * used documents. This widgets works by putting a #GtkRecentChooserWidget inside - * a #GtkDialog. It exposes the #GtkRecentChooserIface interface, so you can use - * all the #GtkRecentChooser functions on the recent chooser dialog as well as - * those for #GtkDialog. - * - * Note that #GtkRecentChooserDialog does not have any methods of its own. - * Instead, you should use the functions that work on a #GtkRecentChooser. - * - * ## Typical usage ## {#gtkrecentchooser-typical-usage} - * - * In the simplest of cases, you can use the following code to use - * a #GtkRecentChooserDialog to select a recently used file: - * - * |[ - * GtkWidget *dialog; - * gint res; - * - * dialog = gtk_recent_chooser_dialog_new ("Recent Documents", - * parent_window, - * _("_Cancel"), - * GTK_RESPONSE_CANCEL, - * _("_Open"), - * GTK_RESPONSE_ACCEPT, - * NULL); - * - * res = gtk_dialog_run (GTK_DIALOG (dialog)); - * if (res == GTK_RESPONSE_ACCEPT) - * { - * GtkRecentInfo *info; - * GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (dialog); - * - * info = gtk_recent_chooser_get_current_item (chooser); - * open_file (gtk_recent_info_get_uri (info)); - * gtk_recent_info_unref (info); - * } - * - * gtk_widget_destroy (dialog); - * ]| - * - * Recently used files are supported since GTK+ 2.10. - */ - - -struct _GtkRecentChooserDialogPrivate -{ - GtkRecentManager *manager; - - GtkWidget *chooser; -}; - -#define GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE(obj) (GTK_RECENT_CHOOSER_DIALOG (obj)->priv) - -static void gtk_recent_chooser_dialog_finalize (GObject *object); - -static void gtk_recent_chooser_dialog_constructed (GObject *object); - -static void gtk_recent_chooser_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_recent_chooser_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDialog, - gtk_recent_chooser_dialog, - GTK_TYPE_DIALOG, - G_ADD_PRIVATE (GtkRecentChooserDialog) - G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, - _gtk_recent_chooser_delegate_iface_init)) - -static void -gtk_recent_chooser_dialog_class_init (GtkRecentChooserDialogClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->set_property = gtk_recent_chooser_dialog_set_property; - gobject_class->get_property = gtk_recent_chooser_dialog_get_property; - gobject_class->constructed = gtk_recent_chooser_dialog_constructed; - gobject_class->finalize = gtk_recent_chooser_dialog_finalize; - - _gtk_recent_chooser_install_properties (gobject_class); -} - -static void -gtk_recent_chooser_dialog_init (GtkRecentChooserDialog *dialog) -{ - GtkRecentChooserDialogPrivate *priv; - GtkWidget *content_area; - GtkDialog *rc_dialog = GTK_DIALOG (dialog); - - priv = gtk_recent_chooser_dialog_get_instance_private (dialog); - dialog->priv = priv; - gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog)); - - content_area = gtk_dialog_get_content_area (rc_dialog); - - gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */ -} - -/* we intercept the GtkRecentChooser::item_activated signal and try to - * make the dialog emit a valid response signal - */ -static void -gtk_recent_chooser_item_activated_cb (GtkRecentChooser *chooser, - gpointer user_data) -{ - GtkDialog *rc_dialog; - GtkRecentChooserDialog *dialog; - GtkWidget *action_area; - GList *children, *l; - - dialog = GTK_RECENT_CHOOSER_DIALOG (user_data); - rc_dialog = GTK_DIALOG (dialog); - - if (gtk_window_activate_default (GTK_WINDOW (dialog))) - return; - - action_area = gtk_dialog_get_action_area (rc_dialog); - children = gtk_container_get_children (GTK_CONTAINER (action_area)); - - for (l = children; l; l = l->next) - { - GtkWidget *widget; - gint response_id; - - widget = GTK_WIDGET (l->data); - response_id = gtk_dialog_get_response_for_widget (rc_dialog, widget); - - if (response_id == GTK_RESPONSE_ACCEPT || - response_id == GTK_RESPONSE_OK || - response_id == GTK_RESPONSE_YES || - response_id == GTK_RESPONSE_APPLY) - { - g_list_free (children); - - gtk_dialog_response (GTK_DIALOG (dialog), response_id); - - return; - } - } - - g_list_free (children); -} - -static void -gtk_recent_chooser_dialog_constructed (GObject *object) -{ - GtkRecentChooserDialogPrivate *priv; - GtkWidget *content_area; - - G_OBJECT_CLASS (gtk_recent_chooser_dialog_parent_class)->constructed (object); - priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object); - - if (priv->manager) - priv->chooser = g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET, - "recent-manager", priv->manager, - NULL); - else - priv->chooser = g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET, NULL); - - g_signal_connect (priv->chooser, "item-activated", - G_CALLBACK (gtk_recent_chooser_item_activated_cb), - object); - - content_area = gtk_dialog_get_content_area (GTK_DIALOG (object)); - - gtk_box_pack_start (GTK_BOX (content_area), - priv->chooser); - - _gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (object), - GTK_RECENT_CHOOSER (priv->chooser)); -} - -static void -gtk_recent_chooser_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserDialogPrivate *priv; - - priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object); - - switch (prop_id) - { - case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER: - priv->manager = g_value_get_object (value); - break; - default: - g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value); - break; - } -} - -static void -gtk_recent_chooser_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserDialogPrivate *priv; - - priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object); - - g_object_get_property (G_OBJECT (priv->chooser), pspec->name, value); -} - -static void -gtk_recent_chooser_dialog_finalize (GObject *object) -{ - GtkRecentChooserDialog *dialog = GTK_RECENT_CHOOSER_DIALOG (object); - - dialog->priv->manager = NULL; - - G_OBJECT_CLASS (gtk_recent_chooser_dialog_parent_class)->finalize (object); -} - -static GtkWidget * -gtk_recent_chooser_dialog_new_valist (const gchar *title, - GtkWindow *parent, - GtkRecentManager *manager, - const gchar *first_button_text, - va_list varargs) -{ - GtkWidget *result; - const char *button_text = first_button_text; - gint response_id; - - result = g_object_new (GTK_TYPE_RECENT_CHOOSER_DIALOG, - "title", title, - "recent-manager", manager, - NULL); - - if (parent) - gtk_window_set_transient_for (GTK_WINDOW (result), parent); - - while (button_text) - { - response_id = va_arg (varargs, gint); - gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id); - button_text = va_arg (varargs, const gchar *); - } - - return result; -} - -/** - * gtk_recent_chooser_dialog_new: - * @title: (allow-none): Title of the dialog, or %NULL - * @parent: (allow-none): Transient parent of the dialog, or %NULL, - * @first_button_text: (allow-none): text to go in the first button, or %NULL - * @...: response ID for the first button, then additional (button, id) - * pairs, ending with %NULL - * - * Creates a new #GtkRecentChooserDialog. This function is analogous to - * gtk_dialog_new_with_buttons(). - * - * Returns: a new #GtkRecentChooserDialog - * - * Since: 2.10 - */ -GtkWidget * -gtk_recent_chooser_dialog_new (const gchar *title, - GtkWindow *parent, - const gchar *first_button_text, - ...) -{ - GtkWidget *result; - va_list varargs; - - va_start (varargs, first_button_text); - result = gtk_recent_chooser_dialog_new_valist (title, - parent, - NULL, - first_button_text, - varargs); - va_end (varargs); - - return result; -} - -/** - * gtk_recent_chooser_dialog_new_for_manager: - * @title: (allow-none): Title of the dialog, or %NULL - * @parent: (allow-none): Transient parent of the dialog, or %NULL, - * @manager: a #GtkRecentManager - * @first_button_text: (allow-none): text to go in the first button, or %NULL - * @...: response ID for the first button, then additional (button, id) - * pairs, ending with %NULL - * - * Creates a new #GtkRecentChooserDialog with a specified recent manager. - * - * This is useful if you have implemented your own recent manager, or if you - * have a customized instance of a #GtkRecentManager object. - * - * Returns: a new #GtkRecentChooserDialog - * - * Since: 2.10 - */ -GtkWidget * -gtk_recent_chooser_dialog_new_for_manager (const gchar *title, - GtkWindow *parent, - GtkRecentManager *manager, - const gchar *first_button_text, - ...) -{ - GtkWidget *result; - va_list varargs; - - va_start (varargs, first_button_text); - result = gtk_recent_chooser_dialog_new_valist (title, - parent, - manager, - first_button_text, - varargs); - va_end (varargs); - - return result; -} diff --git a/gtk/gtkrecentchooserdialog.h b/gtk/gtkrecentchooserdialog.h deleted file mode 100644 index 8511944e98..0000000000 --- a/gtk/gtkrecentchooserdialog.h +++ /dev/null @@ -1,81 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooserdialog.h: Recent files selector dialog - * Copyright (C) 2006 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_CHOOSER_DIALOG_H__ -#define __GTK_RECENT_CHOOSER_DIALOG_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_RECENT_CHOOSER_DIALOG (gtk_recent_chooser_dialog_get_type ()) -#define GTK_RECENT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_DIALOG, GtkRecentChooserDialog)) -#define GTK_IS_RECENT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_DIALOG)) -#define GTK_RECENT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_CHOOSER_DIALOG, GtkRecentChooserDialogClass)) -#define GTK_IS_RECENT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_CHOOSER_DIALOG)) -#define GTK_RECENT_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_CHOOSER_DIALOG, GtkRecentChooserDialogClass)) - -typedef struct _GtkRecentChooserDialog GtkRecentChooserDialog; -typedef struct _GtkRecentChooserDialogClass GtkRecentChooserDialogClass; - -typedef struct _GtkRecentChooserDialogPrivate GtkRecentChooserDialogPrivate; - - -struct _GtkRecentChooserDialog -{ - GtkDialog parent_instance; - - /*< private >*/ - GtkRecentChooserDialogPrivate *priv; -}; - -struct _GtkRecentChooserDialogClass -{ - GtkDialogClass parent_class; - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - - -GDK_AVAILABLE_IN_ALL -GType gtk_recent_chooser_dialog_get_type (void) G_GNUC_CONST; - -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_recent_chooser_dialog_new (const gchar *title, - GtkWindow *parent, - const gchar *first_button_text, - ...) G_GNUC_NULL_TERMINATED; -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_recent_chooser_dialog_new_for_manager (const gchar *title, - GtkWindow *parent, - GtkRecentManager *manager, - const gchar *first_button_text, - ...) G_GNUC_NULL_TERMINATED; - -G_END_DECLS - -#endif /* __GTK_RECENT_CHOOSER_DIALOG_H__ */ diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c deleted file mode 100644 index a99e5cc18f..0000000000 --- a/gtk/gtkrecentchoosermenu.c +++ /dev/null @@ -1,1248 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchoosermenu.c - Recently used items menu widget - * Copyright (C) 2005, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include - -#include "gtkrecentmanager.h" -#include "gtkrecentfilter.h" -#include "gtkrecentchooser.h" -#include "gtkrecentchooserutils.h" -#include "gtkrecentchooserprivate.h" -#include "gtkrecentchoosermenu.h" - -#include "gtkicontheme.h" -#include "gtkintl.h" -#include "gtksettings.h" -#include "gtkmenushell.h" -#include "gtkmenuitem.h" -#include "gtkseparatormenuitem.h" -#include "gtkmenu.h" -#include "gtkimage.h" -#include "gtklabel.h" -#include "gtkbox.h" -#include "gtktooltip.h" -#include "gtktypebuiltins.h" -#include "gtkprivate.h" - -/** - * SECTION:gtkrecentchoosermenu - * @Short_description: Displays recently used files in a menu - * @Title: GtkRecentChooserMenu - * @See_also:#GtkRecentChooser - * - * #GtkRecentChooserMenu is a widget suitable for displaying recently used files - * inside a menu. It can be used to set a sub-menu of a #GtkMenuItem using - * gtk_menu_item_set_submenu(), or as the menu of a #GtkMenuToolButton. - * - * Note that #GtkRecentChooserMenu does not have any methods of its own. Instead, - * you should use the functions that work on a #GtkRecentChooser. - * - * Note also that #GtkRecentChooserMenu does not support multiple filters, as it - * has no way to let the user choose between them as the #GtkRecentChooserWidget - * and #GtkRecentChooserDialog widgets do. Thus using gtk_recent_chooser_add_filter() - * on a #GtkRecentChooserMenu widget will yield the same effects as using - * gtk_recent_chooser_set_filter(), replacing any currently set filter - * with the supplied filter; gtk_recent_chooser_remove_filter() will remove - * any currently set #GtkRecentFilter object and will unset the current filter; - * gtk_recent_chooser_list_filters() will return a list containing a single - * #GtkRecentFilter object. - * - * Recently used files are supported since GTK+ 2.10. - */ - - -struct _GtkRecentChooserMenuPrivate -{ - /* the recent manager object */ - GtkRecentManager *manager; - - /* max size of the menu item label */ - gint label_width; - - gint first_recent_item_pos; - GtkWidget *placeholder; - - /* RecentChooser properties */ - gint limit; - guint show_private : 1; - guint show_not_found : 1; - guint show_tips : 1; - guint show_icons : 1; - guint local_only : 1; - - guint show_numbers : 1; - - GtkRecentSortType sort_type; - GtkRecentSortFunc sort_func; - gpointer sort_data; - GDestroyNotify sort_data_destroy; - - GSList *filters; - GtkRecentFilter *current_filter; - - guint local_manager : 1; - gulong manager_changed_id; - - gulong populate_id; -}; - -enum { - PROP_0, - PROP_SHOW_NUMBERS, -}; - - -#define FALLBACK_ITEM_LIMIT 10 -#define DEFAULT_LABEL_WIDTH 30 - - -static void gtk_recent_chooser_menu_finalize (GObject *object); -static void gtk_recent_chooser_menu_dispose (GObject *object); -static void gtk_recent_chooser_menu_constructed (GObject *object); - -static void gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface); - -static void gtk_recent_chooser_menu_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_recent_chooser_menu_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static gboolean gtk_recent_chooser_menu_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -static gchar * gtk_recent_chooser_menu_get_current_uri (GtkRecentChooser *chooser); -static gboolean gtk_recent_chooser_menu_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -static void gtk_recent_chooser_menu_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri); -static void gtk_recent_chooser_menu_select_all (GtkRecentChooser *chooser); -static void gtk_recent_chooser_menu_unselect_all (GtkRecentChooser *chooser); -static GList * gtk_recent_chooser_menu_get_items (GtkRecentChooser *chooser); -static GtkRecentManager *gtk_recent_chooser_menu_get_recent_manager (GtkRecentChooser *chooser); -static void gtk_recent_chooser_menu_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy); -static void gtk_recent_chooser_menu_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -static void gtk_recent_chooser_menu_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -static GSList * gtk_recent_chooser_menu_list_filters (GtkRecentChooser *chooser); -static void gtk_recent_chooser_menu_set_current_filter (GtkRecentChooserMenu *menu, - GtkRecentFilter *filter); - -static void gtk_recent_chooser_menu_populate (GtkRecentChooserMenu *menu); -static void gtk_recent_chooser_menu_set_show_tips (GtkRecentChooserMenu *menu, - gboolean show_tips); - -static void set_recent_manager (GtkRecentChooserMenu *menu, - GtkRecentManager *manager); - -static void item_activate_cb (GtkWidget *widget, - gpointer user_data); -static void manager_changed_cb (GtkRecentManager *manager, - gpointer user_data); - -G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserMenu, - gtk_recent_chooser_menu, - GTK_TYPE_MENU, - G_ADD_PRIVATE (GtkRecentChooserMenu) - G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, - gtk_recent_chooser_iface_init)) - -static void -gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface) -{ - iface->set_current_uri = gtk_recent_chooser_menu_set_current_uri; - iface->get_current_uri = gtk_recent_chooser_menu_get_current_uri; - iface->select_uri = gtk_recent_chooser_menu_select_uri; - iface->unselect_uri = gtk_recent_chooser_menu_unselect_uri; - iface->select_all = gtk_recent_chooser_menu_select_all; - iface->unselect_all = gtk_recent_chooser_menu_unselect_all; - iface->get_items = gtk_recent_chooser_menu_get_items; - iface->get_recent_manager = gtk_recent_chooser_menu_get_recent_manager; - iface->set_sort_func = gtk_recent_chooser_menu_set_sort_func; - iface->add_filter = gtk_recent_chooser_menu_add_filter; - iface->remove_filter = gtk_recent_chooser_menu_remove_filter; - iface->list_filters = gtk_recent_chooser_menu_list_filters; -} - -static void -gtk_recent_chooser_menu_class_init (GtkRecentChooserMenuClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->constructed = gtk_recent_chooser_menu_constructed; - gobject_class->dispose = gtk_recent_chooser_menu_dispose; - gobject_class->finalize = gtk_recent_chooser_menu_finalize; - gobject_class->set_property = gtk_recent_chooser_menu_set_property; - gobject_class->get_property = gtk_recent_chooser_menu_get_property; - - _gtk_recent_chooser_install_properties (gobject_class); - - /** - * GtkRecentChooserMenu:show-numbers: - * - * Whether the first ten items in the menu should be prepended by - * a number acting as a unique mnemonic. - * - * Since: 2.10 - */ - g_object_class_install_property (gobject_class, - PROP_SHOW_NUMBERS, - g_param_spec_boolean ("show-numbers", - P_("Show Numbers"), - P_("Whether the items should be displayed with a number"), - FALSE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); -} - -static void -gtk_recent_chooser_menu_init (GtkRecentChooserMenu *menu) -{ - GtkRecentChooserMenuPrivate *priv; - - menu->priv = gtk_recent_chooser_menu_get_instance_private (menu); - priv = menu->priv; - - priv->show_icons= TRUE; - priv->show_numbers = FALSE; - priv->show_tips = FALSE; - priv->show_not_found = TRUE; - priv->show_private = FALSE; - priv->local_only = TRUE; - - priv->limit = FALLBACK_ITEM_LIMIT; - priv->sort_type = GTK_RECENT_SORT_NONE; - priv->label_width = DEFAULT_LABEL_WIDTH; - - priv->first_recent_item_pos = -1; - priv->placeholder = NULL; - - priv->current_filter = NULL; -} - -static void -gtk_recent_chooser_menu_finalize (GObject *object) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (object); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - priv->manager = NULL; - - if (priv->sort_data_destroy) - { - priv->sort_data_destroy (priv->sort_data); - priv->sort_data_destroy = NULL; - } - - priv->sort_data = NULL; - priv->sort_func = NULL; - - G_OBJECT_CLASS (gtk_recent_chooser_menu_parent_class)->finalize (object); -} - -static void -gtk_recent_chooser_menu_dispose (GObject *object) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (object); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - if (priv->manager_changed_id) - { - if (priv->manager) - g_signal_handler_disconnect (priv->manager, priv->manager_changed_id); - - priv->manager_changed_id = 0; - } - - if (priv->populate_id) - { - g_source_remove (priv->populate_id); - priv->populate_id = 0; - } - - if (priv->current_filter) - { - g_object_unref (priv->current_filter); - priv->current_filter = NULL; - } - - G_OBJECT_CLASS (gtk_recent_chooser_menu_parent_class)->dispose (object); -} - -static void -gtk_recent_chooser_menu_constructed (GObject *object) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (object); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - G_OBJECT_CLASS (gtk_recent_chooser_menu_parent_class)->constructed (object); - - g_assert (priv->manager); - - /* we create a placeholder menuitem, to be used in case - * the menu is empty. this placeholder will stay around - * for the entire lifetime of the menu, and we just hide it - * when it's not used. we have to do this, and do it here, - * because we need a marker for the beginning of the recent - * items list, so that we can insert the new items at the - * right place when idly populating the menu in case the - * user appended or prepended custom menu items to the - * recent chooser menu widget. - */ - priv->placeholder = gtk_menu_item_new_with_label (_("No items found")); - gtk_widget_set_sensitive (priv->placeholder, FALSE); - g_object_set_data (G_OBJECT (priv->placeholder), - "gtk-recent-menu-placeholder", - GINT_TO_POINTER (TRUE)); - - gtk_menu_shell_insert (GTK_MENU_SHELL (menu), priv->placeholder, 0); - gtk_widget_show (priv->placeholder); - - /* (re)populate the menu */ - gtk_recent_chooser_menu_populate (menu); -} - -static void -gtk_recent_chooser_menu_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (object); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - switch (prop_id) - { - case PROP_SHOW_NUMBERS: - if (priv->show_numbers != g_value_get_boolean (value)) - { - priv->show_numbers = g_value_get_boolean (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER: - set_recent_manager (menu, g_value_get_object (value)); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE: - if (priv->show_private != g_value_get_boolean (value)) - { - priv->show_private = g_value_get_boolean (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND: - if (priv->show_not_found != g_value_get_boolean (value)) - { - priv->show_not_found = g_value_get_boolean (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS: - gtk_recent_chooser_menu_set_show_tips (menu, g_value_get_boolean (value)); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS: - if (priv->show_icons != g_value_get_boolean (value)) - { - priv->show_icons = g_value_get_boolean (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE: - g_warning ("%s: Choosers of type '%s' do not support selecting multiple items.", - G_STRFUNC, - G_OBJECT_TYPE_NAME (object)); - break; - case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY: - if (priv->local_only != g_value_get_boolean (value)) - { - priv->local_only = g_value_get_boolean (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_LIMIT: - if (priv->limit != g_value_get_int (value)) - { - priv->limit = g_value_get_int (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_SORT_TYPE: - if (priv->sort_type != g_value_get_enum (value)) - { - priv->sort_type = g_value_get_enum (value); - g_object_notify_by_pspec (object, pspec); - } - break; - case GTK_RECENT_CHOOSER_PROP_FILTER: - gtk_recent_chooser_menu_set_current_filter (menu, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_recent_chooser_menu_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (object); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - switch (prop_id) - { - case PROP_SHOW_NUMBERS: - g_value_set_boolean (value, priv->show_numbers); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS: - g_value_set_boolean (value, priv->show_tips); - break; - case GTK_RECENT_CHOOSER_PROP_LIMIT: - g_value_set_int (value, priv->limit); - break; - case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY: - g_value_set_boolean (value, priv->local_only); - break; - case GTK_RECENT_CHOOSER_PROP_SORT_TYPE: - g_value_set_enum (value, priv->sort_type); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE: - g_value_set_boolean (value, priv->show_private); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND: - g_value_set_boolean (value, priv->show_not_found); - break; - case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS: - g_value_set_boolean (value, priv->show_icons); - break; - case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE: - g_value_set_boolean (value, FALSE); - break; - case GTK_RECENT_CHOOSER_PROP_FILTER: - g_value_set_object (value, priv->current_filter); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static gboolean -gtk_recent_chooser_menu_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (chooser); - GList *children, *l; - GtkWidget *menu_item = NULL; - gboolean found = FALSE; - gint i = 0; - - children = gtk_container_get_children (GTK_CONTAINER (menu)); - - for (l = children; l != NULL; l = l->next, i++) - { - GtkRecentInfo *info; - - menu_item = GTK_WIDGET (l->data); - - info = g_object_get_data (G_OBJECT (menu_item), "gtk-recent-info"); - if (!info) - continue; - - if (strcmp (uri, gtk_recent_info_get_uri (info)) == 0) - { - gtk_menu_set_active (GTK_MENU (menu), i); - found = TRUE; - - break; - } - } - - g_list_free (children); - - if (!found) - { - g_set_error (error, GTK_RECENT_CHOOSER_ERROR, - GTK_RECENT_CHOOSER_ERROR_NOT_FOUND, - _("No recently used resource found with URI “%s”"), - uri); - } - - return found; -} - -static gchar * -gtk_recent_chooser_menu_get_current_uri (GtkRecentChooser *chooser) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (chooser); - GtkWidget *menu_item; - GtkRecentInfo *info; - - menu_item = gtk_menu_get_active (GTK_MENU (menu)); - if (!menu_item) - return NULL; - - info = g_object_get_data (G_OBJECT (menu_item), "gtk-recent-info"); - if (!info) - return NULL; - - return g_strdup (gtk_recent_info_get_uri (info)); -} - -static gboolean -gtk_recent_chooser_menu_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (chooser); - GList *children, *l; - GtkWidget *menu_item = NULL; - gboolean found = FALSE; - - children = gtk_container_get_children (GTK_CONTAINER (menu)); - for (l = children; l != NULL; l = l->next) - { - GtkRecentInfo *info; - - menu_item = GTK_WIDGET (l->data); - - info = g_object_get_data (G_OBJECT (menu_item), "gtk-recent-info"); - if (!info) - continue; - - if (0 == strcmp (uri, gtk_recent_info_get_uri (info))) - found = TRUE; - } - - g_list_free (children); - - if (!found) - { - g_set_error (error, GTK_RECENT_CHOOSER_ERROR, - GTK_RECENT_CHOOSER_ERROR_NOT_FOUND, - _("No recently used resource found with URI “%s”"), - uri); - return FALSE; - } - else - { - gtk_menu_shell_select_item (GTK_MENU_SHELL (menu), menu_item); - - return TRUE; - } -} - -static void -gtk_recent_chooser_menu_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (chooser); - - gtk_menu_shell_deselect (GTK_MENU_SHELL (menu)); -} - -static void -gtk_recent_chooser_menu_select_all (GtkRecentChooser *chooser) -{ - g_warning ("This function is not implemented for " - "widgets of class '%s'", - g_type_name (G_OBJECT_TYPE (chooser))); -} - -static void -gtk_recent_chooser_menu_unselect_all (GtkRecentChooser *chooser) -{ - g_warning ("This function is not implemented for " - "widgets of class '%s'", - g_type_name (G_OBJECT_TYPE (chooser))); -} - -static void -gtk_recent_chooser_menu_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (chooser); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - if (priv->sort_data_destroy) - { - priv->sort_data_destroy (priv->sort_data); - priv->sort_data_destroy = NULL; - } - - priv->sort_func = NULL; - priv->sort_data = NULL; - priv->sort_data_destroy = NULL; - - if (sort_func) - { - priv->sort_func = sort_func; - priv->sort_data = sort_data; - priv->sort_data_destroy = data_destroy; - } -} - -static GList * -gtk_recent_chooser_menu_get_items (GtkRecentChooser *chooser) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (chooser); - GtkRecentChooserMenuPrivate *priv = menu->priv; - - return _gtk_recent_chooser_get_items (chooser, - priv->current_filter, - priv->sort_func, - priv->sort_data); -} - -static GtkRecentManager * -gtk_recent_chooser_menu_get_recent_manager (GtkRecentChooser *chooser) -{ - GtkRecentChooserMenuPrivate *priv; - - priv = GTK_RECENT_CHOOSER_MENU (chooser)->priv; - - return priv->manager; -} - -static void -gtk_recent_chooser_menu_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - GtkRecentChooserMenu *menu; - - menu = GTK_RECENT_CHOOSER_MENU (chooser); - - gtk_recent_chooser_menu_set_current_filter (menu, filter); -} - -static void -gtk_recent_chooser_menu_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - GtkRecentChooserMenu *menu; - - menu = GTK_RECENT_CHOOSER_MENU (chooser); - - if (filter == menu->priv->current_filter) - { - g_object_unref (menu->priv->current_filter); - menu->priv->current_filter = NULL; - - g_object_notify (G_OBJECT (menu), "filter"); - } -} - -static GSList * -gtk_recent_chooser_menu_list_filters (GtkRecentChooser *chooser) -{ - GtkRecentChooserMenu *menu; - GSList *retval = NULL; - - menu = GTK_RECENT_CHOOSER_MENU (chooser); - - if (menu->priv->current_filter) - retval = g_slist_prepend (retval, menu->priv->current_filter); - - return retval; -} - -static void -gtk_recent_chooser_menu_set_current_filter (GtkRecentChooserMenu *menu, - GtkRecentFilter *filter) -{ - GtkRecentChooserMenuPrivate *priv; - - priv = menu->priv; - - if (priv->current_filter) - g_object_unref (G_OBJECT (priv->current_filter)); - - priv->current_filter = filter; - - if (priv->current_filter) - g_object_ref_sink (priv->current_filter); - - gtk_recent_chooser_menu_populate (menu); - - g_object_notify (G_OBJECT (menu), "filter"); -} - -/* taken from libeel/eel-strings.c */ -static gchar * -escape_underscores (const gchar *string) -{ - gint underscores; - const gchar *p; - gchar *q; - gchar *escaped; - - if (!string) - return NULL; - - underscores = 0; - for (p = string; *p != '\0'; p++) - underscores += (*p == '_'); - - if (underscores == 0) - return g_strdup (string); - - escaped = g_new (char, strlen (string) + underscores + 1); - for (p = string, q = escaped; *p != '\0'; p++, q++) - { - /* Add an extra underscore. */ - if (*p == '_') - *q++ = '_'; - - *q = *p; - } - - *q = '\0'; - - return escaped; -} - -static void -gtk_recent_chooser_menu_add_tip (GtkRecentChooserMenu *menu, - GtkRecentInfo *info, - GtkWidget *item) -{ - GtkRecentChooserMenuPrivate *priv; - gchar *path; - - g_assert (info != NULL); - g_assert (item != NULL); - - priv = menu->priv; - - path = gtk_recent_info_get_uri_display (info); - if (path) - { - gchar *tip_text = g_strdup_printf (_("Open “%s”"), path); - - gtk_widget_set_tooltip_text (item, tip_text); - gtk_widget_set_has_tooltip (item, priv->show_tips); - - g_free (path); - g_free (tip_text); - } -} - -static GtkWidget * -gtk_recent_chooser_menu_create_item (GtkRecentChooserMenu *menu, - GtkRecentInfo *info, - gint count) -{ - GtkRecentChooserMenuPrivate *priv; - gchar *text; - GtkWidget *item, *image, *label; - GIcon *icon; - GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - - g_assert (info != NULL); - - priv = menu->priv; - - if (priv->show_numbers) - { - gchar *name, *escaped; - - name = g_strdup (gtk_recent_info_get_display_name (info)); - if (!name) - name = g_strdup (_("Unknown item")); - - escaped = escape_underscores (name); - - /* avoid clashing mnemonics */ - if (count <= 10) - /* This is the label format that is used for the first 10 items - * in a recent files menu. The %d is the number of the item, - * the %s is the name of the item. Please keep the _ in front - * of the number to give these menu items a mnemonic. - */ - text = g_strdup_printf (C_("recent menu label", "_%d. %s"), count, escaped); - else - /* This is the format that is used for items in a recent files menu. - * The %d is the number of the item, the %s is the name of the item. - */ - text = g_strdup_printf (C_("recent menu label", "%d. %s"), count, escaped); - - label = gtk_label_new_with_mnemonic (text); - - g_free (escaped); - g_free (name); - } - else - { - text = g_strdup (gtk_recent_info_get_display_name (info)); - label = gtk_label_new (text); - } - - g_free (text); - - /* ellipsize the menu item label, in case the recent document - * display name is huge. - */ - gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_label_set_max_width_chars (GTK_LABEL (label), priv->label_width); - - if (priv->show_icons) - { - icon = gtk_recent_info_get_gicon (info); - - image = gtk_image_new_from_gicon (icon); - if (icon) - g_object_unref (icon); - - gtk_container_add (GTK_CONTAINER (box), image); - } - - item = gtk_menu_item_new (); - gtk_container_add (GTK_CONTAINER (box), label); - gtk_container_add (GTK_CONTAINER (item), box); - - g_signal_connect (item, "activate", - G_CALLBACK (item_activate_cb), - menu); - - return item; -} - -static void -gtk_recent_chooser_menu_insert_item (GtkRecentChooserMenu *menu, - GtkWidget *menuitem, - gint position) -{ - GtkRecentChooserMenuPrivate *priv = menu->priv; - gint real_position; - - if (priv->first_recent_item_pos == -1) - { - GList *children, *l; - - children = gtk_container_get_children (GTK_CONTAINER (menu)); - - for (real_position = 0, l = children; - l != NULL; - real_position += 1, l = l->next) - { - GObject *child = l->data; - gboolean is_placeholder = FALSE; - - is_placeholder = - GPOINTER_TO_INT (g_object_get_data (child, "gtk-recent-menu-placeholder")); - - if (is_placeholder) - break; - } - - g_list_free (children); - priv->first_recent_item_pos = real_position; - } - else - real_position = priv->first_recent_item_pos; - - gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, - real_position + position); - gtk_widget_show (menuitem); -} - -/* removes the items we own from the menu */ -static void -gtk_recent_chooser_menu_dispose_items (GtkRecentChooserMenu *menu) -{ - GList *children, *l; - - children = gtk_container_get_children (GTK_CONTAINER (menu)); - for (l = children; l != NULL; l = l->next) - { - GtkWidget *menu_item = GTK_WIDGET (l->data); - gboolean has_mark = FALSE; - - /* check for our mark, in order to remove just the items we own */ - has_mark = - GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "gtk-recent-menu-mark")); - - if (has_mark) - { - GtkRecentInfo *info; - - /* destroy the attached RecentInfo struct, if found */ - info = g_object_get_data (G_OBJECT (menu_item), "gtk-recent-info"); - if (info) - g_object_set_data_full (G_OBJECT (menu_item), "gtk-recent-info", - NULL, NULL); - - /* and finally remove the item from the menu */ - gtk_container_remove (GTK_CONTAINER (menu), menu_item); - } - } - - /* recalculate the position of the first recent item */ - menu->priv->first_recent_item_pos = -1; - - g_list_free (children); -} - -typedef struct -{ - GList *items; - gint n_items; - gint loaded_items; - gint displayed_items; - GtkRecentChooserMenu *menu; - GtkWidget *placeholder; -} MenuPopulateData; - -static MenuPopulateData * -create_menu_populate_data (GtkRecentChooserMenu *menu) -{ - MenuPopulateData *pdata; - - pdata = g_slice_new (MenuPopulateData); - pdata->items = NULL; - pdata->n_items = 0; - pdata->loaded_items = 0; - pdata->displayed_items = 0; - pdata->menu = menu; - pdata->placeholder = g_object_ref (menu->priv->placeholder); - - return pdata; -} - -static void -free_menu_populate_data (MenuPopulateData *pdata) -{ - if (pdata->placeholder) - g_object_unref (pdata->placeholder); - g_slice_free (MenuPopulateData, pdata); -} - -static gboolean -idle_populate_func (gpointer data) -{ - MenuPopulateData *pdata; - GtkRecentChooserMenuPrivate *priv; - GtkRecentInfo *info; - gboolean retval; - GtkWidget *item; - - pdata = (MenuPopulateData *) data; - priv = pdata->menu->priv; - - if (!pdata->items) - { - pdata->items = gtk_recent_chooser_get_items (GTK_RECENT_CHOOSER (pdata->menu)); - if (!pdata->items) - { - /* show the placeholder here */ - gtk_widget_show (pdata->placeholder); - pdata->displayed_items = 1; - priv->populate_id = 0; - - return FALSE; - } - else - gtk_widget_hide (pdata->placeholder); - - pdata->n_items = g_list_length (pdata->items); - pdata->loaded_items = 0; - } - - info = g_list_nth_data (pdata->items, pdata->loaded_items); - item = gtk_recent_chooser_menu_create_item (pdata->menu, - info, - pdata->displayed_items); - if (!item) - goto check_and_return; - - gtk_recent_chooser_menu_add_tip (pdata->menu, info, item); - gtk_recent_chooser_menu_insert_item (pdata->menu, item, - pdata->displayed_items); - - pdata->displayed_items += 1; - - /* mark the menu item as one of our own */ - g_object_set_data (G_OBJECT (item), - "gtk-recent-menu-mark", - GINT_TO_POINTER (TRUE)); - - /* attach the RecentInfo object to the menu item, and own a reference - * to it, so that it will be destroyed with the menu item when it's - * not needed anymore. - */ - g_object_set_data_full (G_OBJECT (item), "gtk-recent-info", - gtk_recent_info_ref (info), - (GDestroyNotify) gtk_recent_info_unref); - -check_and_return: - pdata->loaded_items += 1; - - if (pdata->loaded_items == pdata->n_items) - { - g_list_free_full (pdata->items, (GDestroyNotify) gtk_recent_info_unref); - - priv->populate_id = 0; - - retval = FALSE; - } - else - retval = TRUE; - - return retval; -} - -static void -idle_populate_clean_up (gpointer data) -{ - MenuPopulateData *pdata = data; - - if (pdata->menu->priv->populate_id == 0) - { - /* show the placeholder in case no item survived - * the filtering process in the idle loop - */ - if (!pdata->displayed_items) - gtk_widget_show (pdata->placeholder); - } - - free_menu_populate_data (pdata); -} - -static void -gtk_recent_chooser_menu_populate (GtkRecentChooserMenu *menu) -{ - MenuPopulateData *pdata; - GtkRecentChooserMenuPrivate *priv = menu->priv; - - if (priv->populate_id) - return; - - pdata = create_menu_populate_data (menu); - - /* remove our menu items first */ - gtk_recent_chooser_menu_dispose_items (menu); - - priv->populate_id = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 30, - idle_populate_func, - pdata, - idle_populate_clean_up); - g_source_set_name_by_id (priv->populate_id, "[gtk+] idle_populate_func"); -} - -/* bounce activate signal from the recent menu item widget - * to the recent menu widget - */ -static void -item_activate_cb (GtkWidget *widget, - gpointer user_data) -{ - GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (user_data); - GtkRecentInfo *info = g_object_get_data (G_OBJECT (widget), "gtk-recent-info"); - - gtk_recent_chooser_menu_set_current_uri (chooser, gtk_recent_info_get_uri (info), NULL); - _gtk_recent_chooser_item_activated (chooser); -} - -/* we force a redraw if the manager changes when we are showing */ -static void -manager_changed_cb (GtkRecentManager *manager, - gpointer user_data) -{ - GtkRecentChooserMenu *menu = GTK_RECENT_CHOOSER_MENU (user_data); - - gtk_recent_chooser_menu_populate (menu); -} - -static void -set_recent_manager (GtkRecentChooserMenu *menu, - GtkRecentManager *manager) -{ - GtkRecentChooserMenuPrivate *priv = menu->priv; - - if (priv->manager) - { - if (priv->manager_changed_id) - { - g_signal_handler_disconnect (priv->manager, priv->manager_changed_id); - priv->manager_changed_id = 0; - } - - if (priv->populate_id) - { - g_source_remove (priv->populate_id); - priv->populate_id = 0; - } - - priv->manager = NULL; - } - - if (manager) - priv->manager = manager; - else - priv->manager = gtk_recent_manager_get_default (); - - if (priv->manager) - priv->manager_changed_id = g_signal_connect (priv->manager, "changed", - G_CALLBACK (manager_changed_cb), - menu); -} - -static void -foreach_set_shot_tips (GtkWidget *widget, - gpointer user_data) -{ - GtkRecentChooserMenu *menu = user_data; - GtkRecentChooserMenuPrivate *priv = menu->priv; - gboolean has_mark; - - /* toggle the tooltip only on the items we create */ - has_mark = - GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gtk-recent-menu-mark")); - - if (has_mark) - gtk_widget_set_has_tooltip (widget, priv->show_tips); -} - -static void -gtk_recent_chooser_menu_set_show_tips (GtkRecentChooserMenu *menu, - gboolean show_tips) -{ - GtkRecentChooserMenuPrivate *priv = menu->priv; - - if (priv->show_tips == show_tips) - return; - - priv->show_tips = show_tips; - gtk_container_foreach (GTK_CONTAINER (menu), foreach_set_shot_tips, menu); - g_object_notify (G_OBJECT (menu), "show-tips"); -} - -/* - * Public API - */ - -/** - * gtk_recent_chooser_menu_new: - * - * Creates a new #GtkRecentChooserMenu widget. - * - * This kind of widget shows the list of recently used resources as - * a menu, each item as a menu item. Each item inside the menu might - * have an icon, representing its MIME type, and a number, for mnemonic - * access. - * - * This widget implements the #GtkRecentChooser interface. - * - * This widget creates its own #GtkRecentManager object. See the - * gtk_recent_chooser_menu_new_for_manager() function to know how to create - * a #GtkRecentChooserMenu widget bound to another #GtkRecentManager object. - * - * Returns: a new #GtkRecentChooserMenu - * - * Since: 2.10 - */ -GtkWidget * -gtk_recent_chooser_menu_new (void) -{ - return g_object_new (GTK_TYPE_RECENT_CHOOSER_MENU, - "recent-manager", NULL, - NULL); -} - -/** - * gtk_recent_chooser_menu_new_for_manager: - * @manager: a #GtkRecentManager - * - * Creates a new #GtkRecentChooserMenu widget using @manager as - * the underlying recently used resources manager. - * - * This is useful if you have implemented your own recent manager, - * or if you have a customized instance of a #GtkRecentManager - * object or if you wish to share a common #GtkRecentManager object - * among multiple #GtkRecentChooser widgets. - * - * Returns: a new #GtkRecentChooserMenu, bound to @manager. - * - * Since: 2.10 - */ -GtkWidget * -gtk_recent_chooser_menu_new_for_manager (GtkRecentManager *manager) -{ - g_return_val_if_fail (manager == NULL || GTK_IS_RECENT_MANAGER (manager), NULL); - - return g_object_new (GTK_TYPE_RECENT_CHOOSER_MENU, - "recent-manager", manager, - NULL); -} - -/** - * gtk_recent_chooser_menu_get_show_numbers: - * @menu: a #GtkRecentChooserMenu - * - * Returns the value set by gtk_recent_chooser_menu_set_show_numbers(). - * - * Returns: %TRUE if numbers should be shown. - * - * Since: 2.10 - */ -gboolean -gtk_recent_chooser_menu_get_show_numbers (GtkRecentChooserMenu *menu) -{ - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER_MENU (menu), FALSE); - - return menu->priv->show_numbers; -} - -/** - * gtk_recent_chooser_menu_set_show_numbers: - * @menu: a #GtkRecentChooserMenu - * @show_numbers: whether to show numbers - * - * Sets whether a number should be added to the items of @menu. The - * numbers are shown to provide a unique character for a mnemonic to - * be used inside ten menu item’s label. Only the first the items - * get a number to avoid clashes. - * - * Since: 2.10 - */ -void -gtk_recent_chooser_menu_set_show_numbers (GtkRecentChooserMenu *menu, - gboolean show_numbers) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER_MENU (menu)); - - if (menu->priv->show_numbers == show_numbers) - return; - - menu->priv->show_numbers = show_numbers; - g_object_notify (G_OBJECT (menu), "show-numbers"); -} diff --git a/gtk/gtkrecentchoosermenu.h b/gtk/gtkrecentchoosermenu.h deleted file mode 100644 index 1ae9ad4694..0000000000 --- a/gtk/gtkrecentchoosermenu.h +++ /dev/null @@ -1,77 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchoosermenu.h - Recently used items menu widget - * Copyright (C) 2006, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_CHOOSER_MENU_H__ -#define __GTK_RECENT_CHOOSER_MENU_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_RECENT_CHOOSER_MENU (gtk_recent_chooser_menu_get_type ()) -#define GTK_RECENT_CHOOSER_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenu)) -#define GTK_IS_RECENT_CHOOSER_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_MENU)) -#define GTK_RECENT_CHOOSER_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenuClass)) -#define GTK_IS_RECENT_CHOOSER_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_CHOOSER_MENU)) -#define GTK_RECENT_CHOOSER_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenuClass)) - -typedef struct _GtkRecentChooserMenu GtkRecentChooserMenu; -typedef struct _GtkRecentChooserMenuClass GtkRecentChooserMenuClass; -typedef struct _GtkRecentChooserMenuPrivate GtkRecentChooserMenuPrivate; - -struct _GtkRecentChooserMenu -{ - GtkMenu parent_instance; - - /*< private >*/ - GtkRecentChooserMenuPrivate *priv; -}; - -struct _GtkRecentChooserMenuClass -{ - GtkMenuClass parent_class; - - /* padding for future expansion */ - void (* gtk_recent1) (void); - void (* gtk_recent2) (void); - void (* gtk_recent3) (void); - void (* gtk_recent4) (void); -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_recent_chooser_menu_get_type (void) G_GNUC_CONST; - -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_recent_chooser_menu_new (void); -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_recent_chooser_menu_new_for_manager (GtkRecentManager *manager); - -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_chooser_menu_get_show_numbers (GtkRecentChooserMenu *menu); -GDK_AVAILABLE_IN_ALL -void gtk_recent_chooser_menu_set_show_numbers (GtkRecentChooserMenu *menu, - gboolean show_numbers); - -G_END_DECLS - -#endif /* ! __GTK_RECENT_CHOOSER_MENU_H__ */ diff --git a/gtk/gtkrecentchooserprivate.h b/gtk/gtkrecentchooserprivate.h deleted file mode 100644 index 133885488e..0000000000 --- a/gtk/gtkrecentchooserprivate.h +++ /dev/null @@ -1,40 +0,0 @@ -/* gtkrecentprivatechooser.h - Interface definitions for recent selectors UI - * - * Copyright (C) 2006 Emmanuele Bassi - * - * All rights reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_CHOOSER_PRIVATE_H__ -#define __GTK_RECENT_CHOOSER_PRIVATE_H__ - -#include "gtkrecentmanager.h" -#include "gtkrecentchooser.h" - -G_BEGIN_DECLS - -GtkRecentManager *_gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser); -GList * _gtk_recent_chooser_get_items (GtkRecentChooser *chooser, - GtkRecentFilter *filter, - GtkRecentSortFunc func, - gpointer data); - -void _gtk_recent_chooser_item_activated (GtkRecentChooser *chooser); -void _gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser); - -G_END_DECLS - -#endif /* ! __GTK_RECENT_CHOOSER_PRIVATE_H__ */ diff --git a/gtk/gtkrecentchooserutils.c b/gtk/gtkrecentchooserutils.c deleted file mode 100644 index 8e788b6dd3..0000000000 --- a/gtk/gtkrecentchooserutils.c +++ /dev/null @@ -1,530 +0,0 @@ -/* gtkrecentchooserutils.h - Private utility functions for implementing a - * GtkRecentChooser interface - * - * Copyright (C) 2006 Emmanuele Bassi - * - * All rights reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - * - * Based on gtkfilechooserutils.c: - * Copyright (C) 2003 Red Hat, Inc. - */ - -#include "config.h" - -#include "gtkrecentchooserutils.h" - -/* Methods */ -static void delegate_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy); -static void delegate_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -static void delegate_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter); -static GSList *delegate_list_filters (GtkRecentChooser *chooser); -static gboolean delegate_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -static void delegate_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri); -static GList *delegate_get_items (GtkRecentChooser *chooser); -static GtkRecentManager *delegate_get_recent_manager (GtkRecentChooser *chooser); -static void delegate_select_all (GtkRecentChooser *chooser); -static void delegate_unselect_all (GtkRecentChooser *chooser); -static gboolean delegate_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error); -static gchar * delegate_get_current_uri (GtkRecentChooser *chooser); - -/* Signals */ -static void delegate_notify (GObject *object, - GParamSpec *pspec, - gpointer user_data); -static void delegate_selection_changed (GtkRecentChooser *receiver, - gpointer user_data); -static void delegate_item_activated (GtkRecentChooser *receiver, - gpointer user_data); - -/** - * _gtk_recent_chooser_install_properties: - * @klass: the class structure for a type deriving from #GObject - * - * Installs the necessary properties for a class implementing - * #GtkRecentChooser. A #GtkParamSpecOverride property is installed - * for each property, using the values from the #GtkRecentChooserProp - * enumeration. The caller must make sure itself that the enumeration - * values don’t collide with some other property values they - * are using. - */ -void -_gtk_recent_chooser_install_properties (GObjectClass *klass) -{ - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER, - "recent-manager"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE, - "show-private"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_SHOW_TIPS, - "show-tips"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_SHOW_ICONS, - "show-icons"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND, - "show-not-found"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE, - "select-multiple"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_LIMIT, - "limit"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY, - "local-only"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_SORT_TYPE, - "sort-type"); - g_object_class_override_property (klass, - GTK_RECENT_CHOOSER_PROP_FILTER, - "filter"); -} - -/** - * _gtk_recent_chooser_delegate_iface_init: - * @iface: a #GtkRecentChooserIface - * - * An interface-initialization function for use in cases where - * an object is simply delegating the methods, signals of - * the #GtkRecentChooser interface to another object. - * _gtk_recent_chooser_set_delegate() must be called on each - * instance of the object so that the delegate object can - * be found. - */ -void -_gtk_recent_chooser_delegate_iface_init (GtkRecentChooserIface *iface) -{ - iface->set_current_uri = delegate_set_current_uri; - iface->get_current_uri = delegate_get_current_uri; - iface->select_uri = delegate_select_uri; - iface->unselect_uri = delegate_unselect_uri; - iface->select_all = delegate_select_all; - iface->unselect_all = delegate_unselect_all; - iface->get_items = delegate_get_items; - iface->get_recent_manager = delegate_get_recent_manager; - iface->set_sort_func = delegate_set_sort_func; - iface->add_filter = delegate_add_filter; - iface->remove_filter = delegate_remove_filter; - iface->list_filters = delegate_list_filters; -} - -/** - * _gtk_recent_chooser_set_delegate: - * @receiver: a #GObject implementing #GtkRecentChooser - * @delegate: another #GObject implementing #GtkRecentChooser - * - * Establishes that calls on @receiver for #GtkRecentChooser - * methods should be delegated to @delegate, and that - * #GtkRecentChooser signals emitted on @delegate should be - * forwarded to @receiver. Must be used in conjunction with - * _gtk_recent_chooser_delegate_iface_init(). - */ -void -_gtk_recent_chooser_set_delegate (GtkRecentChooser *receiver, - GtkRecentChooser *delegate) -{ - g_return_if_fail (GTK_IS_RECENT_CHOOSER (receiver)); - g_return_if_fail (GTK_IS_RECENT_CHOOSER (delegate)); - - g_object_set_data (G_OBJECT (receiver), - "gtk-recent-chooser-delegate", delegate); - - g_signal_connect (delegate, "notify", - G_CALLBACK (delegate_notify), receiver); - g_signal_connect (delegate, "selection-changed", - G_CALLBACK (delegate_selection_changed), receiver); - g_signal_connect (delegate, "item-activated", - G_CALLBACK (delegate_item_activated), receiver); -} - -GQuark -_gtk_recent_chooser_delegate_get_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("gtk-recent-chooser-delegate"); - - return quark; -} - -static GtkRecentChooser * -get_delegate (GtkRecentChooser *receiver) -{ - return g_object_get_qdata (G_OBJECT (receiver), - GTK_RECENT_CHOOSER_DELEGATE_QUARK); -} - -static void -delegate_set_sort_func (GtkRecentChooser *chooser, - GtkRecentSortFunc sort_func, - gpointer sort_data, - GDestroyNotify data_destroy) -{ - gtk_recent_chooser_set_sort_func (get_delegate (chooser), - sort_func, - sort_data, - data_destroy); -} - -static void -delegate_add_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - gtk_recent_chooser_add_filter (get_delegate (chooser), filter); -} - -static void -delegate_remove_filter (GtkRecentChooser *chooser, - GtkRecentFilter *filter) -{ - gtk_recent_chooser_remove_filter (get_delegate (chooser), filter); -} - -static GSList * -delegate_list_filters (GtkRecentChooser *chooser) -{ - return gtk_recent_chooser_list_filters (get_delegate (chooser)); -} - -static gboolean -delegate_select_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - return gtk_recent_chooser_select_uri (get_delegate (chooser), uri, error); -} - -static void -delegate_unselect_uri (GtkRecentChooser *chooser, - const gchar *uri) -{ - gtk_recent_chooser_unselect_uri (get_delegate (chooser), uri); -} - -static GList * -delegate_get_items (GtkRecentChooser *chooser) -{ - return gtk_recent_chooser_get_items (get_delegate (chooser)); -} - -static GtkRecentManager * -delegate_get_recent_manager (GtkRecentChooser *chooser) -{ - return _gtk_recent_chooser_get_recent_manager (get_delegate (chooser)); -} - -static void -delegate_select_all (GtkRecentChooser *chooser) -{ - gtk_recent_chooser_select_all (get_delegate (chooser)); -} - -static void -delegate_unselect_all (GtkRecentChooser *chooser) -{ - gtk_recent_chooser_unselect_all (get_delegate (chooser)); -} - -static gboolean -delegate_set_current_uri (GtkRecentChooser *chooser, - const gchar *uri, - GError **error) -{ - return gtk_recent_chooser_set_current_uri (get_delegate (chooser), uri, error); -} - -static gchar * -delegate_get_current_uri (GtkRecentChooser *chooser) -{ - return gtk_recent_chooser_get_current_uri (get_delegate (chooser)); -} - -static void -delegate_notify (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - gpointer iface; - - iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (object)), - gtk_recent_chooser_get_type ()); - if (g_object_interface_find_property (iface, pspec->name)) - g_object_notify (user_data, pspec->name); -} - -static void -delegate_selection_changed (GtkRecentChooser *receiver, - gpointer user_data) -{ - _gtk_recent_chooser_selection_changed (GTK_RECENT_CHOOSER (user_data)); -} - -static void -delegate_item_activated (GtkRecentChooser *receiver, - gpointer user_data) -{ - _gtk_recent_chooser_item_activated (GTK_RECENT_CHOOSER (user_data)); -} - -static gint -sort_recent_items_mru (GtkRecentInfo *a, - GtkRecentInfo *b, - gpointer unused) -{ - g_assert (a != NULL && b != NULL); - - return gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a); -} - -static gint -sort_recent_items_lru (GtkRecentInfo *a, - GtkRecentInfo *b, - gpointer unused) -{ - g_assert (a != NULL && b != NULL); - - return -1 * (gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a)); -} - -typedef struct -{ - GtkRecentSortFunc func; - gpointer data; -} SortRecentData; - -/* our proxy sorting function */ -static gint -sort_recent_items_proxy (gpointer *a, - gpointer *b, - gpointer user_data) -{ - GtkRecentInfo *info_a = (GtkRecentInfo *) a; - GtkRecentInfo *info_b = (GtkRecentInfo *) b; - SortRecentData *sort_recent = user_data; - - if (sort_recent->func) - return (* sort_recent->func) (info_a, info_b, sort_recent->data); - - /* fallback */ - return 0; -} - -static gboolean -get_is_recent_filtered (GtkRecentFilter *filter, - GtkRecentInfo *info) -{ - GtkRecentFilterInfo filter_info; - GtkRecentFilterFlags needed; - gboolean retval; - - g_assert (info != NULL); - - needed = gtk_recent_filter_get_needed (filter); - - filter_info.contains = GTK_RECENT_FILTER_URI | GTK_RECENT_FILTER_MIME_TYPE; - - filter_info.uri = gtk_recent_info_get_uri (info); - filter_info.mime_type = gtk_recent_info_get_mime_type (info); - - if (needed & GTK_RECENT_FILTER_DISPLAY_NAME) - { - filter_info.display_name = gtk_recent_info_get_display_name (info); - filter_info.contains |= GTK_RECENT_FILTER_DISPLAY_NAME; - } - else - filter_info.uri = NULL; - - if (needed & GTK_RECENT_FILTER_APPLICATION) - { - filter_info.applications = (const gchar **) gtk_recent_info_get_applications (info, NULL); - filter_info.contains |= GTK_RECENT_FILTER_APPLICATION; - } - else - filter_info.applications = NULL; - - if (needed & GTK_RECENT_FILTER_GROUP) - { - filter_info.groups = (const gchar **) gtk_recent_info_get_groups (info, NULL); - filter_info.contains |= GTK_RECENT_FILTER_GROUP; - } - else - filter_info.groups = NULL; - - if (needed & GTK_RECENT_FILTER_AGE) - { - filter_info.age = gtk_recent_info_get_age (info); - filter_info.contains |= GTK_RECENT_FILTER_AGE; - } - else - filter_info.age = -1; - - retval = gtk_recent_filter_filter (filter, &filter_info); - - /* these we own */ - if (filter_info.applications) - g_strfreev ((gchar **) filter_info.applications); - if (filter_info.groups) - g_strfreev ((gchar **) filter_info.groups); - - return !retval; -} - -/* - * _gtk_recent_chooser_get_items: - * @chooser: a #GtkRecentChooser - * @filter: a #GtkRecentFilter - * @sort_func: (allow-none): sorting function, or %NULL - * @sort_data: (allow-none): sorting function data, or %NULL - * - * Default implementation for getting the filtered, sorted and - * clamped list of recently used resources from a #GtkRecentChooser. - * This function should be used by implementations of the - * #GtkRecentChooser interface inside the GtkRecentChooser::get_items - * vfunc. - * - * Returns: a list of #GtkRecentInfo objects - */ -GList * -_gtk_recent_chooser_get_items (GtkRecentChooser *chooser, - GtkRecentFilter *filter, - GtkRecentSortFunc sort_func, - gpointer sort_data) -{ - GtkRecentManager *manager; - gint limit; - GtkRecentSortType sort_type; - GList *items; - GCompareDataFunc compare_func; - gint length; - - g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL); - - manager = _gtk_recent_chooser_get_recent_manager (chooser); - if (!manager) - return NULL; - - items = gtk_recent_manager_get_items (manager); - if (!items) - return NULL; - - limit = gtk_recent_chooser_get_limit (chooser); - if (limit == 0) - return NULL; - - if (filter) - { - GList *filter_items, *l; - gboolean local_only = FALSE; - gboolean show_private = FALSE; - gboolean show_not_found = FALSE; - - g_object_get (G_OBJECT (chooser), - "local-only", &local_only, - "show-private", &show_private, - "show-not-found", &show_not_found, - NULL); - - filter_items = NULL; - for (l = items; l != NULL; l = l->next) - { - GtkRecentInfo *info = l->data; - gboolean remove_item = FALSE; - - if (get_is_recent_filtered (filter, info)) - remove_item = TRUE; - - if (local_only && !gtk_recent_info_is_local (info)) - remove_item = TRUE; - - if (!show_private && gtk_recent_info_get_private_hint (info)) - remove_item = TRUE; - - if (!show_not_found && !gtk_recent_info_exists (info)) - remove_item = TRUE; - - if (!remove_item) - filter_items = g_list_prepend (filter_items, info); - else - gtk_recent_info_unref (info); - } - - g_list_free (items); - items = filter_items; - } - - if (!items) - return NULL; - - sort_type = gtk_recent_chooser_get_sort_type (chooser); - switch (sort_type) - { - case GTK_RECENT_SORT_NONE: - compare_func = NULL; - break; - case GTK_RECENT_SORT_MRU: - compare_func = (GCompareDataFunc) sort_recent_items_mru; - break; - case GTK_RECENT_SORT_LRU: - compare_func = (GCompareDataFunc) sort_recent_items_lru; - break; - case GTK_RECENT_SORT_CUSTOM: - compare_func = (GCompareDataFunc) sort_recent_items_proxy; - break; - default: - g_assert_not_reached (); - break; - } - - if (compare_func) - { - SortRecentData sort_recent; - - sort_recent.func = sort_func; - sort_recent.data = sort_data; - - items = g_list_sort_with_data (items, compare_func, &sort_recent); - } - - length = g_list_length (items); - if ((limit != -1) && (length > limit)) - { - GList *clamp, *l; - - clamp = g_list_nth (items, limit - 1); - if (!clamp) - return items; - - l = clamp->next; - clamp->next = NULL; - - g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref); - } - - return items; -} diff --git a/gtk/gtkrecentchooserutils.h b/gtk/gtkrecentchooserutils.h deleted file mode 100644 index 70e88dbcc3..0000000000 --- a/gtk/gtkrecentchooserutils.h +++ /dev/null @@ -1,60 +0,0 @@ -/* gtkrecentchooserutils.h - Private utility functions for implementing a - * GtkRecentChooser interface - * - * Copyright (C) 2006 Emmanuele Bassi - * - * All rights reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - * - * Based on gtkfilechooserutils.h: - * Copyright (C) 2003 Red Hat, Inc. - */ - -#ifndef __GTK_RECENT_CHOOSER_UTILS_H__ -#define __GTK_RECENT_CHOOSER_UTILS_H__ - -#include "gtkrecentchooserprivate.h" - -G_BEGIN_DECLS - - -#define GTK_RECENT_CHOOSER_DELEGATE_QUARK (_gtk_recent_chooser_delegate_get_quark ()) - -typedef enum { - GTK_RECENT_CHOOSER_PROP_FIRST = 0x3000, - GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER, - GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE, - GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND, - GTK_RECENT_CHOOSER_PROP_SHOW_TIPS, - GTK_RECENT_CHOOSER_PROP_SHOW_ICONS, - GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE, - GTK_RECENT_CHOOSER_PROP_LIMIT, - GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY, - GTK_RECENT_CHOOSER_PROP_SORT_TYPE, - GTK_RECENT_CHOOSER_PROP_FILTER, - GTK_RECENT_CHOOSER_PROP_LAST -} GtkRecentChooserProp; - -void _gtk_recent_chooser_install_properties (GObjectClass *klass); - -void _gtk_recent_chooser_delegate_iface_init (GtkRecentChooserIface *iface); -void _gtk_recent_chooser_set_delegate (GtkRecentChooser *receiver, - GtkRecentChooser *delegate); - -GQuark _gtk_recent_chooser_delegate_get_quark (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __GTK_RECENT_CHOOSER_UTILS_H__ */ diff --git a/gtk/gtkrecentchooserwidget.c b/gtk/gtkrecentchooserwidget.c deleted file mode 100644 index 862277e377..0000000000 --- a/gtk/gtkrecentchooserwidget.c +++ /dev/null @@ -1,237 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooserwidget.c: embeddable recently used resources chooser widget - * Copyright (C) 2006 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include "gtkrecentchooserwidget.h" -#include "gtkrecentchooserdefault.h" -#include "gtkrecentchooserutils.h" -#include "gtkorientable.h" -#include "gtktypebuiltins.h" - -/** - * SECTION:gtkrecentchooserwidget - * @Short_description: Displays recently used files - * @Title: GtkRecentChooserWidget - * @See_also:#GtkRecentChooser, #GtkRecentChooserDialog - * - * #GtkRecentChooserWidget is a widget suitable for selecting recently used - * files. It is the main building block of a #GtkRecentChooserDialog. Most - * applications will only need to use the latter; you can use - * #GtkRecentChooserWidget as part of a larger window if you have special needs. - * - * Note that #GtkRecentChooserWidget does not have any methods of its own. - * Instead, you should use the functions that work on a #GtkRecentChooser. - * - * Recently used files are supported since GTK+ 2.10. - */ - - -struct _GtkRecentChooserWidgetPrivate -{ - GtkRecentManager *manager; - - GtkWidget *chooser; -}; - -static void gtk_recent_chooser_widget_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_recent_chooser_widget_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gtk_recent_chooser_widget_finalize (GObject *object); - - -G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserWidget, - gtk_recent_chooser_widget, - GTK_TYPE_WIDGET, - G_ADD_PRIVATE (GtkRecentChooserWidget) - G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, - _gtk_recent_chooser_delegate_iface_init)) - -static void -gtk_recent_chooser_widget_constructed (GObject *gobject) -{ - GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (gobject); - - self->priv->chooser = _gtk_recent_chooser_default_new (self->priv->manager); - - gtk_widget_set_parent (self->priv->chooser, GTK_WIDGET (self)); - - _gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (self), - GTK_RECENT_CHOOSER (self->priv->chooser)); -} - -static void -gtk_recent_chooser_widget_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserWidgetPrivate *priv; - - priv = gtk_recent_chooser_widget_get_instance_private (GTK_RECENT_CHOOSER_WIDGET (object)); - - switch (prop_id) - { - case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER: - priv->manager = g_value_get_object (value); - break; - default: - g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value); - break; - } -} - -static void -gtk_recent_chooser_widget_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkRecentChooserWidgetPrivate *priv; - - priv = gtk_recent_chooser_widget_get_instance_private (GTK_RECENT_CHOOSER_WIDGET (object)); - - g_object_get_property (G_OBJECT (priv->chooser), pspec->name, value); -} - -static void -gtk_recent_chooser_widget_finalize (GObject *object) -{ - GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (object); - - self->priv->manager = NULL; - - gtk_widget_unparent (self->priv->chooser); - - G_OBJECT_CLASS (gtk_recent_chooser_widget_parent_class)->finalize (object); -} - -static void -gtk_recent_chooser_widget_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (widget); - GtkRecentChooserWidgetPrivate *priv = gtk_recent_chooser_widget_get_instance_private (self); - - gtk_widget_measure (priv->chooser, orientation, for_size, - minimum, natural, - minimum_baseline, natural_baseline); -} - -static void -gtk_recent_chooser_widget_snapshot (GtkWidget *widget, - GtkSnapshot *snapshot) -{ - GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (widget); - GtkRecentChooserWidgetPrivate *priv = gtk_recent_chooser_widget_get_instance_private (self); - - gtk_widget_snapshot_child (widget, priv->chooser, snapshot); -} - -static void -gtk_recent_chooser_widget_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline, - GtkAllocation *out_clip) -{ - GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (widget); - GtkRecentChooserWidgetPrivate *priv = gtk_recent_chooser_widget_get_instance_private (self); - - GTK_WIDGET_CLASS (gtk_recent_chooser_widget_parent_class)->size_allocate (widget, allocation, -1, out_clip); - - gtk_widget_size_allocate (priv->chooser, allocation, -1, out_clip); -} - -static void -gtk_recent_chooser_widget_class_init (GtkRecentChooserWidgetClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gobject_class->constructed = gtk_recent_chooser_widget_constructed; - gobject_class->set_property = gtk_recent_chooser_widget_set_property; - gobject_class->get_property = gtk_recent_chooser_widget_get_property; - gobject_class->finalize = gtk_recent_chooser_widget_finalize; - - widget_class->measure = gtk_recent_chooser_widget_measure; - widget_class->size_allocate = gtk_recent_chooser_widget_size_allocate; - widget_class->snapshot = gtk_recent_chooser_widget_snapshot; - - _gtk_recent_chooser_install_properties (gobject_class); -} - -static void -gtk_recent_chooser_widget_init (GtkRecentChooserWidget *widget) -{ - widget->priv = gtk_recent_chooser_widget_get_instance_private (widget); - - gtk_widget_set_has_window (GTK_WIDGET (widget), FALSE); -} - -/* - * Public API - */ - -/** - * gtk_recent_chooser_widget_new: - * - * Creates a new #GtkRecentChooserWidget object. This is an embeddable widget - * used to access the recently used resources list. - * - * Returns: a new #GtkRecentChooserWidget - * - * Since: 2.10 - */ -GtkWidget * -gtk_recent_chooser_widget_new (void) -{ - return g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET, NULL); -} - -/** - * gtk_recent_chooser_widget_new_for_manager: - * @manager: a #GtkRecentManager - * - * Creates a new #GtkRecentChooserWidget with a specified recent manager. - * - * This is useful if you have implemented your own recent manager, or if you - * have a customized instance of a #GtkRecentManager object. - * - * Returns: a new #GtkRecentChooserWidget - * - * Since: 2.10 - */ -GtkWidget * -gtk_recent_chooser_widget_new_for_manager (GtkRecentManager *manager) -{ - g_return_val_if_fail (manager == NULL || GTK_IS_RECENT_MANAGER (manager), NULL); - - return g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET, - "recent-manager", manager, - NULL); -} diff --git a/gtk/gtkrecentchooserwidget.h b/gtk/gtkrecentchooserwidget.h deleted file mode 100644 index c5dcc65f3c..0000000000 --- a/gtk/gtkrecentchooserwidget.h +++ /dev/null @@ -1,71 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentchooserwidget.h: embeddable recently used resources chooser widget - * Copyright (C) 2006 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_CHOOSER_WIDGET_H__ -#define __GTK_RECENT_CHOOSER_WIDGET_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_RECENT_CHOOSER_WIDGET (gtk_recent_chooser_widget_get_type ()) -#define GTK_RECENT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_WIDGET, GtkRecentChooserWidget)) -#define GTK_IS_RECENT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_WIDGET)) -#define GTK_RECENT_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_CHOOSER_WIDGET, GtkRecentChooserWidgetClass)) -#define GTK_IS_RECENT_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_CHOOSER_WIDGET)) -#define GTK_RECENT_CHOOSER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_CHOOSER_WIDGET, GtkRecentChooserWidgetClass)) - -typedef struct _GtkRecentChooserWidget GtkRecentChooserWidget; -typedef struct _GtkRecentChooserWidgetClass GtkRecentChooserWidgetClass; - -typedef struct _GtkRecentChooserWidgetPrivate GtkRecentChooserWidgetPrivate; - -struct _GtkRecentChooserWidget -{ - GtkWidget parent_instance; - - /*< private >*/ - GtkRecentChooserWidgetPrivate *priv; -}; - -struct _GtkRecentChooserWidgetClass -{ - GtkWidgetClass parent_class; - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_recent_chooser_widget_get_type (void) G_GNUC_CONST; -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_recent_chooser_widget_new (void); -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_recent_chooser_widget_new_for_manager (GtkRecentManager *manager); - -G_END_DECLS - -#endif /* __GTK_RECENT_CHOOSER_WIDGET_H__ */ diff --git a/gtk/gtkrecentfilter.c b/gtk/gtkrecentfilter.c deleted file mode 100644 index 506e0aa82b..0000000000 --- a/gtk/gtkrecentfilter.c +++ /dev/null @@ -1,837 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentfilter.h - Filter object for recently used resources - * Copyright (C) 2006, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/** - * SECTION:gtkrecentfilter - * @Short_Description: A filter for selecting a subset of recently used files - * @Title: GtkRecentFilter - * - * A #GtkRecentFilter can be used to restrict the files being shown - * in a #GtkRecentChooser. Files can be filtered based on their name - * (with gtk_recent_filter_add_pattern()), on their mime type (with - * gtk_file_filter_add_mime_type()), on the application that has - * registered them (with gtk_recent_filter_add_application()), or by - * a custom filter function (with gtk_recent_filter_add_custom()). - * - * Filtering by mime type handles aliasing and subclassing of mime - * types; e.g. a filter for text/plain also matches a file with mime - * type application/rtf, since application/rtf is a subclass of text/plain. - * Note that #GtkRecentFilter allows wildcards for the subtype of a - * mime type, so you can e.g. filter for image/\*. - * - * Normally, filters are used by adding them to a #GtkRecentChooser, - * see gtk_recent_chooser_add_filter(), but it is also possible to - * manually use a filter on a file with gtk_recent_filter_filter(). - * - * Recently used files are supported since GTK+ 2.10. - * - * ## GtkRecentFilter as GtkBuildable - * - * The GtkRecentFilter implementation of the GtkBuildable interface - * supports adding rules using the , and - * elements and listing the rules within. Specifying - * a , or has the same effect as - * calling gtk_recent_filter_add_mime_type(), - * gtk_recent_filter_add_pattern() or gtk_recent_filter_add_application(). - * - * An example of a UI definition fragment specifying GtkRecentFilter rules: - * |[ - * - * - * text/plain - * image/png - * - * - * *.txt - * *.png - * - * - * gimp - * gedit - * glade - * - * - * ]| - */ - -#include "config.h" -#include - -#include - -#include "gtkrecentfilter.h" -#include "gtkbuildable.h" -#include "gtkbuilderprivate.h" -#include "gtkintl.h" -#include "gtkprivate.h" - -static void gtk_recent_filter_buildable_init (GtkBuildableIface *iface); -static gboolean gtk_recent_filter_buildable_custom_tag_start (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - GMarkupParser *parser, - gpointer *data); -static void gtk_recent_filter_buildable_custom_tag_end (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - gpointer *data); - -typedef struct _GtkRecentFilterClass GtkRecentFilterClass; -typedef struct _FilterRule FilterRule; - -typedef enum { - FILTER_RULE_URI, - FILTER_RULE_DISPLAY_NAME, - FILTER_RULE_MIME_TYPE, - FILTER_RULE_PIXBUF_FORMATS, - FILTER_RULE_APPLICATION, - FILTER_RULE_AGE, - FILTER_RULE_GROUP, - FILTER_RULE_CUSTOM -} FilterRuleType; - -struct _GtkRecentFilter -{ - GInitiallyUnowned parent_instance; - - gchar *name; - GSList *rules; - - GtkRecentFilterFlags needed; -}; - -struct _GtkRecentFilterClass -{ - GInitiallyUnownedClass parent_class; -}; - -struct _FilterRule -{ - FilterRuleType type; - GtkRecentFilterFlags needed; - - union { - gchar *uri; - gchar *pattern; - gchar *mime_type; - GSList *pixbuf_formats; - gchar *application; - gchar *group; - gint age; - struct { - GtkRecentFilterFunc func; - gpointer data; - GDestroyNotify data_destroy; - } custom; - } u; -}; - -G_DEFINE_TYPE_WITH_CODE (GtkRecentFilter, gtk_recent_filter, G_TYPE_INITIALLY_UNOWNED, - G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, - gtk_recent_filter_buildable_init)) - - -static void -filter_rule_free (FilterRule *rule) -{ - switch (rule->type) - { - case FILTER_RULE_MIME_TYPE: - g_free (rule->u.mime_type); - break; - case FILTER_RULE_URI: - g_free (rule->u.uri); - break; - case FILTER_RULE_DISPLAY_NAME: - g_free (rule->u.pattern); - break; - case FILTER_RULE_PIXBUF_FORMATS: - g_slist_free (rule->u.pixbuf_formats); - break; - case FILTER_RULE_AGE: - break; - case FILTER_RULE_APPLICATION: - g_free (rule->u.application); - break; - case FILTER_RULE_GROUP: - g_free (rule->u.group); - break; - case FILTER_RULE_CUSTOM: - if (rule->u.custom.data_destroy) - rule->u.custom.data_destroy (rule->u.custom.data); - break; - default: - g_assert_not_reached (); - break; - } - - g_free (rule); -} - -static void -gtk_recent_filter_finalize (GObject *object) -{ - GtkRecentFilter *filter = GTK_RECENT_FILTER (object); - - g_free (filter->name); - g_slist_free_full (filter->rules, (GDestroyNotify) filter_rule_free); - - G_OBJECT_CLASS (gtk_recent_filter_parent_class)->finalize (object); -} - -static void -gtk_recent_filter_class_init (GtkRecentFilterClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->finalize = gtk_recent_filter_finalize; -} - -static void -gtk_recent_filter_init (GtkRecentFilter *filter) -{ - -} - - -/* - * GtkBuildable implementation - */ -static void -gtk_recent_filter_buildable_init (GtkBuildableIface *iface) -{ - iface->custom_tag_start = gtk_recent_filter_buildable_custom_tag_start; - iface->custom_tag_end = gtk_recent_filter_buildable_custom_tag_end; -} - - -typedef enum { - PARSE_MIME_TYPES, - PARSE_PATTERNS, - PARSE_APPLICATIONS -} ParserType; - -typedef struct { - GtkRecentFilter *filter; - GtkBuilder *builder; - ParserType type; - GString *string; - gboolean parsing; -} SubParserData; - -static void -parser_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **names, - const gchar **values, - gpointer user_data, - GError **error) -{ - SubParserData *data = (SubParserData*)user_data; - - if (!g_markup_collect_attributes (element_name, names, values, error, - G_MARKUP_COLLECT_INVALID, NULL, NULL, - G_MARKUP_COLLECT_INVALID)) - { - _gtk_builder_prefix_error (data->builder, context, error); - return; - } - - if (strcmp (element_name, "mime-types") == 0 || - strcmp (element_name, "patterns") == 0 || - strcmp (element_name, "applications") == 0) - { - if (!_gtk_builder_check_parent (data->builder, context, "object", error)) - return; - } - else if (strcmp (element_name, "mime-type") == 0) - { - if (!_gtk_builder_check_parent (data->builder, context, "mime-types", error)) - return; - - data->parsing = TRUE; - } - else if (strcmp (element_name, "pattern") == 0) - { - if (!_gtk_builder_check_parent (data->builder, context, "patterns", error)) - return; - - data->parsing = TRUE; - } - else if (strcmp (element_name, "application") == 0) - { - if (!_gtk_builder_check_parent (data->builder, context, "applications", error)) - return; - - data->parsing = TRUE; - } - else - { - _gtk_builder_error_unhandled_tag (data->builder, context, - "GtkRecentFilter", element_name, - error); - } -} - -static void -parser_text_element (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error) -{ - SubParserData *data = (SubParserData*)user_data; - - if (data->parsing) - g_string_append_len (data->string, text, text_len); -} - -static void -parser_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error) -{ - SubParserData *data = (SubParserData*)user_data; - - if (data->string) - { - switch (data->type) - { - case PARSE_MIME_TYPES: - gtk_recent_filter_add_mime_type (data->filter, data->string->str); - break; - case PARSE_PATTERNS: - gtk_recent_filter_add_pattern (data->filter, data->string->str); - break; - case PARSE_APPLICATIONS: - gtk_recent_filter_add_application (data->filter, data->string->str); - break; - default: - break; - } - } - - g_string_set_size (data->string, 0); - data->parsing = FALSE; -} - -static const GMarkupParser sub_parser = - { - parser_start_element, - parser_end_element, - parser_text_element, - }; - -static gboolean -gtk_recent_filter_buildable_custom_tag_start (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - GMarkupParser *parser, - gpointer *parser_data) -{ - SubParserData *data = NULL; - - if (strcmp (tagname, "mime-types") == 0) - { - data = g_slice_new0 (SubParserData); - data->string = g_string_new (""); - data->type = PARSE_MIME_TYPES; - data->filter = GTK_RECENT_FILTER (buildable); - data->builder = builder; - - *parser = sub_parser; - *parser_data = data; - } - else if (strcmp (tagname, "patterns") == 0) - { - data = g_slice_new0 (SubParserData); - data->string = g_string_new (""); - data->type = PARSE_PATTERNS; - data->filter = GTK_RECENT_FILTER (buildable); - data->builder = builder; - - *parser = sub_parser; - *parser_data = data; - } - else if (strcmp (tagname, "applications") == 0) - { - data = g_slice_new0 (SubParserData); - data->string = g_string_new (""); - data->type = PARSE_APPLICATIONS; - data->filter = GTK_RECENT_FILTER (buildable); - data->builder = builder; - - *parser = sub_parser; - *parser_data = data; - } - - return data != NULL; -} - -static void -gtk_recent_filter_buildable_custom_tag_end (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - gpointer *parser_data) -{ - if (strcmp (tagname, "mime-types") == 0 || - strcmp (tagname, "patterns") == 0 || - strcmp (tagname, "applications") == 0) - { - SubParserData *data = (SubParserData*)parser_data; - - g_string_free (data->string, TRUE); - g_slice_free (SubParserData, data); - } -} - -/* - * Public API - */ - -/** - * gtk_recent_filter_new: - * - * Creates a new #GtkRecentFilter with no rules added to it. - * Such filter does not accept any recently used resources, so is not - * particularly useful until you add rules with - * gtk_recent_filter_add_pattern(), gtk_recent_filter_add_mime_type(), - * gtk_recent_filter_add_application(), gtk_recent_filter_add_age(). - * To create a filter that accepts any recently used resource, use: - * |[ - * GtkRecentFilter *filter = gtk_recent_filter_new (); - * gtk_recent_filter_add_pattern (filter, "*"); - * ]| - * - * Returns: a new #GtkRecentFilter - * - * Since: 2.10 - */ -GtkRecentFilter * -gtk_recent_filter_new (void) -{ - return g_object_new (GTK_TYPE_RECENT_FILTER, NULL); -} - -/** - * gtk_recent_filter_set_name: - * @filter: a #GtkRecentFilter - * @name: then human readable name of @filter - * - * Sets the human-readable name of the filter; this is the string - * that will be displayed in the recently used resources selector - * user interface if there is a selectable list of filters. - * - * Since: 2.10 - */ -void -gtk_recent_filter_set_name (GtkRecentFilter *filter, - const gchar *name) -{ - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - - g_free (filter->name); - - if (name) - filter->name = g_strdup (name); -} - -/** - * gtk_recent_filter_get_name: - * @filter: a #GtkRecentFilter - * - * Gets the human-readable name for the filter. - * See gtk_recent_filter_set_name(). - * - * Returns: (nullable): the name of the filter, or %NULL. The returned string - * is owned by the filter object and should not be freed. - * - * Since: 2.10 - */ -const gchar * -gtk_recent_filter_get_name (GtkRecentFilter *filter) -{ - g_return_val_if_fail (GTK_IS_RECENT_FILTER (filter), NULL); - - return filter->name; -} - -/** - * gtk_recent_filter_get_needed: - * @filter: a #GtkRecentFilter - * - * Gets the fields that need to be filled in for the #GtkRecentFilterInfo - * passed to gtk_recent_filter_filter() - * - * This function will not typically be used by applications; it - * is intended principally for use in the implementation of - * #GtkRecentChooser. - * - * Returns: bitfield of flags indicating needed fields when - * calling gtk_recent_filter_filter() - * - * Since: 2.10 - */ -GtkRecentFilterFlags -gtk_recent_filter_get_needed (GtkRecentFilter *filter) -{ - return filter->needed; -} - -static void -recent_filter_add_rule (GtkRecentFilter *filter, - FilterRule *rule) -{ - filter->needed |= rule->needed; - filter->rules = g_slist_append (filter->rules, rule); -} - -/** - * gtk_recent_filter_add_mime_type: - * @filter: a #GtkRecentFilter - * @mime_type: a MIME type - * - * Adds a rule that allows resources based on their registered MIME type. - * - * Since: 2.10 - */ -void -gtk_recent_filter_add_mime_type (GtkRecentFilter *filter, - const gchar *mime_type) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - g_return_if_fail (mime_type != NULL); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_MIME_TYPE; - rule->needed = GTK_RECENT_FILTER_MIME_TYPE; - rule->u.mime_type = g_strdup (mime_type); - - recent_filter_add_rule (filter, rule); -} - -/** - * gtk_recent_filter_add_pattern: - * @filter: a #GtkRecentFilter - * @pattern: a file pattern - * - * Adds a rule that allows resources based on a pattern matching their - * display name. - * - * Since: 2.10 - */ -void -gtk_recent_filter_add_pattern (GtkRecentFilter *filter, - const gchar *pattern) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - g_return_if_fail (pattern != NULL); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_DISPLAY_NAME; - rule->needed = GTK_RECENT_FILTER_DISPLAY_NAME; - rule->u.pattern = g_strdup (pattern); - - recent_filter_add_rule (filter, rule); -} - -/** - * gtk_recent_filter_add_pixbuf_formats: - * @filter: a #GtkRecentFilter - * - * Adds a rule allowing image files in the formats supported - * by GdkPixbuf. - * - * Since: 2.10 - */ -void -gtk_recent_filter_add_pixbuf_formats (GtkRecentFilter *filter) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_PIXBUF_FORMATS; - rule->needed = GTK_RECENT_FILTER_MIME_TYPE; - rule->u.pixbuf_formats = gdk_pixbuf_get_formats (); - - recent_filter_add_rule (filter, rule); -} - -/** - * gtk_recent_filter_add_application: - * @filter: a #GtkRecentFilter - * @application: an application name - * - * Adds a rule that allows resources based on the name of the application - * that has registered them. - * - * Since: 2.10 - */ -void -gtk_recent_filter_add_application (GtkRecentFilter *filter, - const gchar *application) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - g_return_if_fail (application != NULL); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_APPLICATION; - rule->needed = GTK_RECENT_FILTER_APPLICATION; - rule->u.application = g_strdup (application); - - recent_filter_add_rule (filter, rule); -} - -/** - * gtk_recent_filter_add_group: - * @filter: a #GtkRecentFilter - * @group: a group name - * - * Adds a rule that allows resources based on the name of the group - * to which they belong - * - * Since: 2.10 - */ -void -gtk_recent_filter_add_group (GtkRecentFilter *filter, - const gchar *group) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - g_return_if_fail (group != NULL); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_GROUP; - rule->needed = GTK_RECENT_FILTER_GROUP; - rule->u.group = g_strdup (group); - - recent_filter_add_rule (filter, rule); -} - -/** - * gtk_recent_filter_add_age: - * @filter: a #GtkRecentFilter - * @days: number of days - * - * Adds a rule that allows resources based on their age - that is, the number - * of days elapsed since they were last modified. - * - * Since: 2.10 - */ -void -gtk_recent_filter_add_age (GtkRecentFilter *filter, - gint days) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_AGE; - rule->needed = GTK_RECENT_FILTER_AGE; - rule->u.age = days; - - recent_filter_add_rule (filter, rule); -} - -/** - * gtk_recent_filter_add_custom: - * @filter: a #GtkRecentFilter - * @needed: bitfield of flags indicating the information that the custom - * filter function needs. - * @func: callback function; if the function returns %TRUE, then - * the file will be displayed. - * @data: data to pass to @func - * @data_destroy: function to call to free @data when it is no longer needed. - * - * Adds a rule to a filter that allows resources based on a custom callback - * function. The bitfield @needed which is passed in provides information - * about what sorts of information that the filter function needs; - * this allows GTK+ to avoid retrieving expensive information when - * it isn’t needed by the filter. - * - * Since: 2.10 - **/ -void -gtk_recent_filter_add_custom (GtkRecentFilter *filter, - GtkRecentFilterFlags needed, - GtkRecentFilterFunc func, - gpointer data, - GDestroyNotify data_destroy) -{ - FilterRule *rule; - - g_return_if_fail (GTK_IS_RECENT_FILTER (filter)); - g_return_if_fail (func != NULL); - - rule = g_new0 (FilterRule, 1); - rule->type = FILTER_RULE_CUSTOM; - rule->needed = needed; - rule->u.custom.func = func; - rule->u.custom.data = data; - rule->u.custom.data_destroy = data_destroy; - - recent_filter_add_rule (filter, rule); -} - - -/** - * gtk_recent_filter_filter: - * @filter: a #GtkRecentFilter - * @filter_info: a #GtkRecentFilterInfo containing information - * about a recently used resource - * - * Tests whether a file should be displayed according to @filter. - * The #GtkRecentFilterInfo @filter_info should include - * the fields returned from gtk_recent_filter_get_needed(), and - * must set the #GtkRecentFilterInfo.contains field of @filter_info - * to indicate which fields have been set. - * - * This function will not typically be used by applications; it - * is intended principally for use in the implementation of - * #GtkRecentChooser. - * - * Returns: %TRUE if the file should be displayed - * - * Since: 2.10 - */ -gboolean -gtk_recent_filter_filter (GtkRecentFilter *filter, - const GtkRecentFilterInfo *filter_info) -{ - GSList *l; - - g_return_val_if_fail (GTK_IS_RECENT_FILTER (filter), FALSE); - g_return_val_if_fail (filter_info != NULL, FALSE); - - for (l = filter->rules; l != NULL; l = l->next) - { - FilterRule *rule = (FilterRule *) l->data; - - if ((filter_info->contains & rule->needed) != rule->needed) - continue; - - switch (rule->type) - { - case FILTER_RULE_MIME_TYPE: - if (filter_info->mime_type != NULL) - { - gchar *filter_content_type, *rule_content_type; - gboolean match; - - filter_content_type = g_content_type_from_mime_type (filter_info->mime_type); - rule_content_type = g_content_type_from_mime_type (rule->u.mime_type); - match = g_content_type_is_a (filter_content_type, rule_content_type); - g_free (filter_content_type); - g_free (rule_content_type); - - if (match) - return TRUE; - } - break; - case FILTER_RULE_APPLICATION: - if (filter_info->applications) - { - gint i; - - for (i = 0; filter_info->applications[i] != NULL; i++) - { - if (strcmp (filter_info->applications[i], rule->u.application) == 0) - return TRUE; - } - } - break; - case FILTER_RULE_GROUP: - if (filter_info->groups) - { - gint i; - - for (i = 0; filter_info->groups[i] != NULL; i++) - { - if (strcmp (filter_info->groups[i], rule->u.group) == 0) - return TRUE; - } - } - break; - case FILTER_RULE_PIXBUF_FORMATS: - { - GSList *list; - if (!filter_info->mime_type) - break; - - for (list = rule->u.pixbuf_formats; list; list = list->next) - { - gint i; - gchar **mime_types; - - mime_types = gdk_pixbuf_format_get_mime_types (list->data); - - for (i = 0; mime_types[i] != NULL; i++) - { - if (strcmp (mime_types[i], filter_info->mime_type) == 0) - { - g_strfreev (mime_types); - return TRUE; - } - } - - g_strfreev (mime_types); - } - break; - } - case FILTER_RULE_URI: - if ((filter_info->uri != NULL) && - _gtk_fnmatch (rule->u.uri, filter_info->uri, FALSE)) - return TRUE; - break; - case FILTER_RULE_DISPLAY_NAME: - if ((filter_info->display_name != NULL) && - _gtk_fnmatch (rule->u.pattern, filter_info->display_name, FALSE)) - return TRUE; - break; - case FILTER_RULE_AGE: - if ((filter_info->age != -1) && - (filter_info->age < rule->u.age)) - return TRUE; - break; - case FILTER_RULE_CUSTOM: - if (rule->u.custom.func (filter_info, rule->u.custom.data)) - return TRUE; - break; - default: - g_assert_not_reached (); - break; - } - } - - return FALSE; -} diff --git a/gtk/gtkrecentfilter.h b/gtk/gtkrecentfilter.h deleted file mode 100644 index 2c428df8a5..0000000000 --- a/gtk/gtkrecentfilter.h +++ /dev/null @@ -1,150 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkrecentfilter.h - Filter object for recently used resources - * Copyright (C) 2006, Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_RECENT_FILTER_H__ -#define __GTK_RECENT_FILTER_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_RECENT_FILTER (gtk_recent_filter_get_type ()) -#define GTK_RECENT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_FILTER, GtkRecentFilter)) -#define GTK_IS_RECENT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_FILTER)) - -typedef struct _GtkRecentFilter GtkRecentFilter; -typedef struct _GtkRecentFilterInfo GtkRecentFilterInfo; - -/** - * GtkRecentFilterFlags: - * @GTK_RECENT_FILTER_URI: the URI of the file being tested - * @GTK_RECENT_FILTER_DISPLAY_NAME: the string that will be used to - * display the file in the recent chooser - * @GTK_RECENT_FILTER_MIME_TYPE: the mime type of the file - * @GTK_RECENT_FILTER_APPLICATION: the list of applications that have - * registered the file - * @GTK_RECENT_FILTER_GROUP: the groups to which the file belongs to - * @GTK_RECENT_FILTER_AGE: the number of days elapsed since the file - * has been registered - * - * These flags indicate what parts of a #GtkRecentFilterInfo struct - * are filled or need to be filled. - */ -typedef enum { - GTK_RECENT_FILTER_URI = 1 << 0, - GTK_RECENT_FILTER_DISPLAY_NAME = 1 << 1, - GTK_RECENT_FILTER_MIME_TYPE = 1 << 2, - GTK_RECENT_FILTER_APPLICATION = 1 << 3, - GTK_RECENT_FILTER_GROUP = 1 << 4, - GTK_RECENT_FILTER_AGE = 1 << 5 -} GtkRecentFilterFlags; - -/** - * GtkRecentFilterFunc: - * @filter_info: a #GtkRecentFilterInfo that is filled according - * to the @needed flags passed to gtk_recent_filter_add_custom() - * @user_data: user data passed to gtk_recent_filter_add_custom() - * - * The type of function that is used with custom filters, - * see gtk_recent_filter_add_custom(). - * - * Returns: %TRUE if the file should be displayed - */ -typedef gboolean (*GtkRecentFilterFunc) (const GtkRecentFilterInfo *filter_info, - gpointer user_data); - - -/** - * GtkRecentFilterInfo: - * @contains: #GtkRecentFilterFlags to indicate which fields are set. - * @uri: (nullable): The URI of the file being tested. - * @display_name: (nullable): The string that will be used to display - * the file in the recent chooser. - * @mime_type: (nullable): MIME type of the file. - * @applications: (nullable) (array zero-terminated=1): The list of - * applications that have registered the file. - * @groups: (nullable) (array zero-terminated=1): The groups to which - * the file belongs to. - * @age: The number of days elapsed since the file has been - * registered. - * - * A GtkRecentFilterInfo struct is used - * to pass information about the tested file to gtk_recent_filter_filter(). - */ -struct _GtkRecentFilterInfo -{ - GtkRecentFilterFlags contains; - - const gchar *uri; - const gchar *display_name; - const gchar *mime_type; - const gchar **applications; - const gchar **groups; - - gint age; -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_recent_filter_get_type (void) G_GNUC_CONST; - -GDK_AVAILABLE_IN_ALL -GtkRecentFilter * gtk_recent_filter_new (void); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_set_name (GtkRecentFilter *filter, - const gchar *name); -GDK_AVAILABLE_IN_ALL -const gchar * gtk_recent_filter_get_name (GtkRecentFilter *filter); - -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_mime_type (GtkRecentFilter *filter, - const gchar *mime_type); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_pattern (GtkRecentFilter *filter, - const gchar *pattern); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_pixbuf_formats (GtkRecentFilter *filter); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_application (GtkRecentFilter *filter, - const gchar *application); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_group (GtkRecentFilter *filter, - const gchar *group); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_age (GtkRecentFilter *filter, - gint days); -GDK_AVAILABLE_IN_ALL -void gtk_recent_filter_add_custom (GtkRecentFilter *filter, - GtkRecentFilterFlags needed, - GtkRecentFilterFunc func, - gpointer data, - GDestroyNotify data_destroy); - -GDK_AVAILABLE_IN_ALL -GtkRecentFilterFlags gtk_recent_filter_get_needed (GtkRecentFilter *filter); -GDK_AVAILABLE_IN_ALL -gboolean gtk_recent_filter_filter (GtkRecentFilter *filter, - const GtkRecentFilterInfo *filter_info); - -G_END_DECLS - -#endif /* ! __GTK_RECENT_FILTER_H__ */ diff --git a/gtk/meson.build b/gtk/meson.build index 4d22655d8c..b80ec6aae8 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -121,7 +121,6 @@ gtk_private_sources = files([ 'gtkprivate.c', 'gtkprogresstracker.c', 'gtkquery.c', - 'gtkrecentchooserutils.c', 'gtksearchengine.c', 'gtksearchenginemodel.c', 'gtksearchenginesimple.c', @@ -280,12 +279,6 @@ gtk_public_sources = files([ 'gtkradiotoolbutton.c', 'gtkrange.c', 'gtkrbtree.c', - 'gtkrecentchooser.c', - 'gtkrecentchooserdefault.c', - 'gtkrecentchooserdialog.c', - 'gtkrecentchoosermenu.c', - 'gtkrecentchooserwidget.c', - 'gtkrecentfilter.c', 'gtkrecentmanager.c', 'gtkrender.c', 'gtkrenderbackground.c', @@ -377,7 +370,6 @@ gtk_private_type_headers = files([ gtk_private_headers = gtk_private_type_headers + files([ 'gtkrbtree.h', - 'gtkrecentchooserutils.h', ]) gtk_public_headers = files([ @@ -521,11 +513,6 @@ gtk_public_headers = files([ 'gtkradiomenuitem.h', 'gtkradiotoolbutton.h', 'gtkrange.h', - 'gtkrecentchooser.h', - 'gtkrecentchooserdialog.h', - 'gtkrecentchoosermenu.h', - 'gtkrecentchooserwidget.h', - 'gtkrecentfilter.h', 'gtkrecentmanager.h', 'gtkrender.h', 'gtkrevealer.h', diff --git a/gtk/ui/gtkrecentchooserdefault.ui b/gtk/ui/gtkrecentchooserdefault.ui deleted file mode 100644 index b34431c3a1..0000000000 --- a/gtk/ui/gtkrecentchooserdefault.ui +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/gtk/ui/gtkrecentchooserdefault.ui.h b/gtk/ui/gtkrecentchooserdefault.ui.h deleted file mode 100644 index 9fdfda393e..0000000000 --- a/gtk/ui/gtkrecentchooserdefault.ui.h +++ /dev/null @@ -1 +0,0 @@ -N_("Select which type of documents are shown"); diff --git a/po-properties/POTFILES.in b/po-properties/POTFILES.in index b686f46ad4..93cc710a54 100644 --- a/po-properties/POTFILES.in +++ b/po-properties/POTFILES.in @@ -226,9 +226,6 @@ gtk/gtkradiobutton.c gtk/gtkradiomenuitem.c gtk/gtkradiotoolbutton.c gtk/gtkrange.c -gtk/gtkrecentchooser.c -gtk/gtkrecentchooserdefault.c -gtk/gtkrecentchoosermenu.c gtk/gtkrecentmanager.c gtk/gtkrevealer.c gtk/gtkscalebutton.c diff --git a/po-properties/POTFILES.skip b/po-properties/POTFILES.skip index a8ecc5f6b1..416b27c0a7 100644 --- a/po-properties/POTFILES.skip +++ b/po-properties/POTFILES.skip @@ -145,8 +145,6 @@ gtk/ui/gtkplacesviewrow.ui gtk/ui/gtkplacesview.ui gtk/ui/gtkprintunixdialog.ui gtk/ui/gtkprintunixdialog.ui.h -gtk/ui/gtkrecentchooserdefault.ui -gtk/ui/gtkrecentchooserdefault.ui.h gtk/ui/gtksidebarrow.ui gtk/ui/gtkvolumebutton.ui gtk/ui/gtkvolumebutton.ui.h diff --git a/tests/meson.build b/tests/meson.build index 1e43fa24f8..75e2d30b1c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -72,8 +72,6 @@ gtk_tests = [ ['testoverlay'], ['testoverlaystyleclass'], ['testprint', ['testprintfileoperation.c']], - ['testrecentchooser'], - ['testrecentchoosermenu'], ['testscale'], ['testselectionmode'], ['testspinbutton'], diff --git a/tests/popupat.ui b/tests/popupat.ui index e23163c7ec..fbe8c7ad1d 100644 --- a/tests/popupat.ui +++ b/tests/popupat.ui @@ -2864,27 +2864,6 @@ False - - - True - False - 20 - - - 10 - - - - - True - False - GtkRecentChooserDefault - - - 10 - False - - True diff --git a/tests/testrecentchooser.c b/tests/testrecentchooser.c deleted file mode 100644 index a2d133d0dd..0000000000 --- a/tests/testrecentchooser.c +++ /dev/null @@ -1,200 +0,0 @@ -/* testrecentchooser.c - * Copyright (C) 2006 Emmanuele Bassi. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include - -#ifdef G_OS_WIN32 -# include -# define localtime_r(t,b) *(b) = localtime (t) -# ifndef S_ISREG -# define S_ISREG(m) ((m) & _S_IFREG) -# endif -#endif - -static void -print_current_item (GtkRecentChooser *chooser) -{ - gchar *uri; - - uri = gtk_recent_chooser_get_current_uri (chooser); - g_print ("Current item changed :\n %s\n", uri ? uri : "null"); - g_free (uri); -} - -static void -print_selected (GtkRecentChooser *chooser) -{ - gsize uris_len, i; - gchar **uris = gtk_recent_chooser_get_uris (chooser, &uris_len); - - g_print ("Selection changed :\n"); - for (i = 0; i < uris_len; i++) - g_print (" %s\n", uris[i]); - g_print ("\n"); - - g_strfreev (uris); -} - -static void -response_cb (GtkDialog *dialog, - gint response_id) -{ - if (response_id == GTK_RESPONSE_OK) - { - } - else - g_print ("Dialog was closed\n"); - - gtk_main_quit (); -} - -static void -filter_changed (GtkRecentChooserDialog *dialog, - gpointer data) -{ - g_print ("recent filter changed\n"); -} - -static void -notify_multiple_cb (GtkWidget *dialog, - GParamSpec *pspec, - GtkWidget *button) -{ - gboolean multiple; - - multiple = gtk_recent_chooser_get_select_multiple (GTK_RECENT_CHOOSER (dialog)); - - gtk_widget_set_sensitive (button, multiple); -} - -static void -kill_dependent (GtkWindow *win, - GtkWidget *dep) -{ - gtk_widget_destroy (dep); - g_object_unref (dep); -} - -int -main (int argc, - char *argv[]) -{ - GtkWidget *control_window; - GtkWidget *vbbox; - GtkWidget *button; - GtkWidget *dialog; - GtkRecentFilter *filter; - gint i; - gboolean multiple = FALSE; - - gtk_init (); - - /* to test rtl layout, set RTL=1 in the environment */ - if (g_getenv ("RTL")) - gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); - - for (i = 1; i < argc; i++) - { - if (!strcmp ("--multiple", argv[i])) - multiple = TRUE; - } - - dialog = g_object_new (GTK_TYPE_RECENT_CHOOSER_DIALOG, - "select-multiple", multiple, - "show-tips", TRUE, - "show-icons", TRUE, - NULL); - gtk_window_set_title (GTK_WINDOW (dialog), "Select a file"); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - "_Cancel", GTK_RESPONSE_CANCEL, - "_Open", GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - g_signal_connect (dialog, "item-activated", - G_CALLBACK (print_current_item), NULL); - g_signal_connect (dialog, "selection-changed", - G_CALLBACK (print_selected), NULL); - g_signal_connect (dialog, "response", - G_CALLBACK (response_cb), NULL); - - /* filters */ - filter = gtk_recent_filter_new (); - gtk_recent_filter_set_name (filter, "All Files"); - gtk_recent_filter_add_pattern (filter, "*"); - gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter); - - filter = gtk_recent_filter_new (); - gtk_recent_filter_set_name (filter, "Only PDF Files"); - gtk_recent_filter_add_mime_type (filter, "application/pdf"); - gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter); - - g_signal_connect (dialog, "notify::filter", - G_CALLBACK (filter_changed), NULL); - - gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (dialog), filter); - - filter = gtk_recent_filter_new (); - gtk_recent_filter_set_name (filter, "PNG and JPEG"); - gtk_recent_filter_add_mime_type (filter, "image/png"); - gtk_recent_filter_add_mime_type (filter, "image/jpeg"); - gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter); - - gtk_widget_show (dialog); - - control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - vbbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL); - gtk_container_add (GTK_CONTAINER (control_window), vbbox); - - button = gtk_button_new_with_mnemonic ("_Select all"); - gtk_widget_set_sensitive (button, multiple); - gtk_container_add (GTK_CONTAINER (vbbox), button); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_recent_chooser_select_all), dialog); - g_signal_connect (dialog, "notify::select-multiple", - G_CALLBACK (notify_multiple_cb), button); - - button = gtk_button_new_with_mnemonic ("_Unselect all"); - gtk_container_add (GTK_CONTAINER (vbbox), button); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_recent_chooser_unselect_all), dialog); - - gtk_widget_show (control_window); - - g_object_ref (control_window); - g_signal_connect (dialog, "destroy", - G_CALLBACK (kill_dependent), control_window); - - g_object_ref (dialog); - gtk_main (); - gtk_widget_destroy (dialog); - g_object_unref (dialog); - - return 0; -} diff --git a/tests/testrecentchoosermenu.c b/tests/testrecentchoosermenu.c deleted file mode 100644 index 0a8d278837..0000000000 --- a/tests/testrecentchoosermenu.c +++ /dev/null @@ -1,183 +0,0 @@ -/* testrecentchoosermenu.c - Test GtkRecentChooserMenu - * Copyright (C) 2007 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - */ - -#include "config.h" -#include - -static GtkRecentManager *manager = NULL; -static GtkWidget *window = NULL; -static GtkWidget *label = NULL; - -static void -item_activated_cb (GtkRecentChooser *chooser, - gpointer data) -{ - GtkRecentInfo *info; - GString *text; - gchar *label_text; - - info = gtk_recent_chooser_get_current_item (chooser); - if (!info) - { - g_warning ("Unable to retrieve the current item, aborting..."); - return; - } - - text = g_string_new ("Selected recent item:\n"); - g_string_append_printf (text, " URI: %s\n", - gtk_recent_info_get_uri (info)); - g_string_append_printf (text, " MIME Type: %s\n", - gtk_recent_info_get_mime_type (info)); - - label_text = g_string_free (text, FALSE); - gtk_label_set_text (GTK_LABEL (label), label_text); - - gtk_recent_info_unref (info); - g_free (label_text); -} - -static GtkWidget * -create_recent_chooser_menu (gint limit) -{ - GtkWidget *menu; - GtkRecentFilter *filter; - GtkWidget *menuitem; - - menu = gtk_recent_chooser_menu_new_for_manager (manager); - - if (limit > 0) - gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (menu), limit); - gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (menu), TRUE); - gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (menu), TRUE); - gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (menu), TRUE); - gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu), - GTK_RECENT_SORT_MRU); - gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (menu), - TRUE); - - filter = gtk_recent_filter_new (); - gtk_recent_filter_set_name (filter, "Gedit files"); - gtk_recent_filter_add_application (filter, "gedit"); - gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter); - gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (menu), filter); - - g_signal_connect (menu, "item-activated", - G_CALLBACK (item_activated_cb), - NULL); - - menuitem = gtk_separator_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_label ("Test prepend"); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_label ("Test append"); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_mnemonic ("Clear"); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - return menu; -} - -static GtkWidget * -create_file_menu (GtkAccelGroup *accelgroup) -{ - GtkWidget *menu; - GtkWidget *menuitem; - GtkWidget *recentmenu; - - menu = gtk_menu_new (); - - menuitem = gtk_menu_item_new_with_mnemonic ("_New"); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_mnemonic ("_Open"); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_mnemonic ("_Open Recent"); - recentmenu = create_recent_chooser_menu (-1); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), recentmenu); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_mnemonic ("_Quit"); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - return menu; -} - -int -main (int argc, char *argv[]) -{ - GtkWidget *box; - GtkWidget *menubar; - GtkWidget *menuitem; - GtkWidget *menu; - GtkWidget *button; - GtkAccelGroup *accel_group; - - gtk_init (); - - manager = gtk_recent_manager_get_default (); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), -1, -1); - gtk_window_set_title (GTK_WINDOW (window), "Recent Chooser Menu Test"); - g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); - - accel_group = gtk_accel_group_new (); - gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); - - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_container_add (GTK_CONTAINER (window), box); - - menubar = gtk_menu_bar_new (); - gtk_box_pack_start (GTK_BOX (box), menubar); - - menu = create_file_menu (accel_group); - menuitem = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); - - menu = create_recent_chooser_menu (4); - menuitem = gtk_menu_item_new_with_mnemonic ("_Recently Used"); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); - - label = gtk_label_new ("No recent item selected"); - gtk_box_pack_start (GTK_BOX (box), label); - - button = gtk_button_new_with_label ("Close"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), - window); - gtk_box_pack_end (GTK_BOX (box), button); - gtk_widget_set_can_default (button, TRUE); - gtk_widget_grab_default (button); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/testsuite/gtk/templates.c b/testsuite/gtk/templates.c index 8344cd5c8a..affd0845a4 100644 --- a/testsuite/gtk/templates.c +++ b/testsuite/gtk/templates.c @@ -303,16 +303,6 @@ test_font_chooser_dialog_basic (void) gtk_widget_destroy (widget); } -static void -test_recent_chooser_widget_basic (void) -{ - GtkWidget *widget; - - widget = gtk_recent_chooser_widget_new (); - g_assert (GTK_IS_RECENT_CHOOSER_WIDGET (widget)); - gtk_widget_destroy (widget); -} - #ifdef HAVE_UNIX_PRINT_WIDGETS static void test_page_setup_unix_dialog_basic (void) @@ -378,7 +368,6 @@ main (int argc, char **argv) g_test_add_func ("/Template/GtkFontButton/Basic", test_font_button_basic); g_test_add_func ("/Template/GtkFontChooserWidget/Basic", test_font_chooser_widget_basic); g_test_add_func ("/Template/GtkFontChooserDialog/Basic", test_font_chooser_dialog_basic); - g_test_add_func ("/Template/GtkRecentChooserWidget/Basic", test_recent_chooser_widget_basic); #ifdef HAVE_UNIX_PRINT_WIDGETS g_test_add_func ("/Template/UnixPrint/GtkPageSetupUnixDialog/Basic", test_page_setup_unix_dialog_basic); -- 2.30.2